3

Is it possible to clear the page cache every hour in W3 total cache? I have a dynamic website (plugin) with data that updates maybe every couple minutes so I want to clear the cache every hour so the data is something like up-to-date.

Now I dont use the page cache otherwise the data is not up-to-date but it really slows down my sites response time and I really need to improve it!

Is this possible with W3 total settings or something?

Regards

Joep

user2812779
  • 193
  • 3
  • 19

1 Answers1

2

Put this in your child theme functions.php

// Scheduled Action Hook

function w3_flush_cache( ) {
    $w3_plugin_totalcache->flush_all();
}

// Schedule Cron Job Event

function w3tc_cache_flush() {
    if ( ! wp_next_scheduled( 'w3_flush_cache' ) ) {
        wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'w3_flush_cache' );    
    }
}

add_action( 'wp', 'w3tc_cache_flush' );
Mhluzi Bhaka
  • 1,364
  • 3
  • 19
  • 42