WordPress function W3 Total Cache automatically clear cache daily/weekly
WordPress W3 Total Cache Auto Cache Flush Automatically Empty

Nothing is worse than when the cache still shows old data despite the page being updated, old CSS files are loaded, and even display errors occur. These are unfortunately the pitfalls of WordPress caching plugins like W3 Total Cache, WP Super Cache, Cachify, and many others.

After we also had problems with a complex client website and outdated CSS files repeatedly caused incorrect displays on mobile devices, a solution was needed. So, as a WordPress agency, we decided to find a flexible, automatic, and effective solution.

The solution for automatically clearing the W3 Total Cache

To edit the functions.php, you need FTP access or, alternatively, direct access via the backend (administration interface). Connect via the FTP server or call up the following URL: YOUR-DOMAIN.de/wp-admin/theme-editor.php?file=functions.php. Please copy the following code to the end of the functions.php in the (child) template folder.

 
 // Automatically clear W3 Total Cache
 function w3_flush_cache( ) {
 $w3_plugin_totalcache->flush_all();
 }
 // Function when W3 Total Cache should be cleared
 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' );

You can replace the red-highlighted parameter with the following values:

  • hourly
  • twicedaily
  • daily

Further information on the timestamp parameters can be found here. You can learn how to clear the cache manually here.

Florian Ibe

Für Fragen rund um WordPress und entsprechender WordPress-Hilfe:

E-Mail: fi@vastcob.com

Florian Ibe

The 5 best tips for WordPress
Register now and secure these valuable free tips like 968 others!


Florian
Florian
has found his calling through passion. Fundamentally honest and direct, he advises everyone from sole proprietors to founders and startups, as well as business and management levels of SMEs. As a consultant, he understands how to reduce complex relationships to their essence and develop a direct message for customers and employees with a sustainable strategy and optimization.

Comments are closed.


Probably the newest best tool & software offers with a lifetime license

Our recommendation:

Screenshot of bit.ly

Pay once for software access & enjoy it for a lifetime