Title: Automatically Purge
Last modified: February 13, 2017

---

# Automatically Purge

 *  [beardedbrewer](https://wordpress.org/support/users/beardedbrewer/)
 * (@beardedbrewer)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/automatically-purge/)
 * Hello,
    I have some code that may or may not flush the cache automatically and
   wanted to check with you folks first. I am not sure it will work and I don’t 
   want to corrupt my functions.php file.
 *     ```
       // 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' ), 'daily', 'w3_flush_cache' );
         }
       }
       add_action( 'wp', 'w3tc_cache_flush' );
       ```
   

The topic ‘Automatically Purge’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [beardedbrewer](https://wordpress.org/support/users/beardedbrewer/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/automatically-purge/)
 * Status: not resolved