Title: CRON cache flush
Last modified: August 31, 2016

---

# CRON cache flush

 *  Resolved [vojtechm](https://wordpress.org/support/users/vojtechm/)
 * (@vojtechm)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/)
 * Hello,
 * is there a way to set CRON for flushing the cache? Is it enough just to remove
   content of the folder with cached files or is there some smarter way to do the
   trick?
 * Can someone please help me?
 * Thank you very much.
    Br, Vojta
 * [https://wordpress.org/plugins/cachify/](https://wordpress.org/plugins/cachify/)

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Support [Torsten Landsiedel](https://wordpress.org/support/users/zodiac1978/)
 * (@zodiac1978)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232388)
 * Why do you want to do that? You shouldn’t delete the complete cache without a
   reason. Of course you can just delete all the cache files, but this just works
   if you have used the HDD method.
 * You can use the WordPress cron in this way to flush the whole cache:
 *     ```
       if ( ! wp_next_scheduled( 'my_cachify_flush_cache' ) ) {
           wp_schedule_event( time(), 'twicedaily', 'my_cachify_flush_cache' );
       }
   
       add_action( 'my_cachify_flush_cache', array( 'Cachify', 'flush_total_cache' ) );
       ```
   
 * Maybe you can work something out with this starting point.
 * All the best,
    Torsten
 *  Thread Starter [vojtechm](https://wordpress.org/support/users/vojtechm/)
 * (@vojtechm)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232540)
 * Hi,
 * thank you for info. All I need is to remove cache files (or flush cache), like
   you said, once a day after midnight. I use HDD method but I don’t how to do so.
   Is there any script for it?
 * I can’t get your script working. Where shall I put it?
 * Thank you very much.
    Br, Vojta
 *  [mupa](https://wordpress.org/support/users/mupa/)
 * (@mupa)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232541)
 * I’m interested in that topic as well. I tried out this solution [https://wordpress.org/support/topic/flush-cache-and-rebuild?replies=3](https://wordpress.org/support/topic/flush-cache-and-rebuild?replies=3)
   but it doesn’t work.
    My questions are:
 * Is this the right way to flush and rebuild the cache via Cron for db storage,
   or is this the solution for hdd caching?
 * My page is hosted under a shared host, so i don’t have the possibility to look
   up server logs. Is there another way to debug a cron job script?
 * My intention to flush and rebuild the cache is cause my RSS feed won’t be updated
   in the cached version. So i thought rebuilding the cache once an hour is a good
   solution. If there is another one (for example to exclude parts of a website)
   please post it here.
 * Thanks in advance
    Mupa
 *  [mupa](https://wordpress.org/support/users/mupa/)
 * (@mupa)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232544)
 * No ideas?
 *  Plugin Support [Torsten Landsiedel](https://wordpress.org/support/users/zodiac1978/)
 * (@zodiac1978)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232547)
 * > I can’t get your script working. Where shall I put it?
 * You can make a functionality plugin out of it:
    [https://gist.github.com/Zodiac1978/1d9f33ef1be377869ad3](https://gist.github.com/Zodiac1978/1d9f33ef1be377869ad3)
 * Or you can put this code in your `functions.php`of your (child) theme. But you
   should know, that an update of the theme maybe overwrites your addition.
 * You can find valid values here:
    [https://codex.wordpress.org/Function_Reference/wp_schedule_event](https://codex.wordpress.org/Function_Reference/wp_schedule_event)(
   so I think you want to use “daily”)
 * > My intention to flush and rebuild the cache is cause my RSS feed won’t be updated
   > in the cached version. So i thought rebuilding the cache once an hour is a 
   > good solution. If there is another one (for example to exclude parts of a website)
   > please post it here.
 * A cache which is deleted before it is really used seems to be not very useful
   IMHO.
 * I’ve opened up a Github issue for our developers, maybe they can help:
    [https://github.com/pluginkollektiv/cachify/issues/26](https://github.com/pluginkollektiv/cachify/issues/26)
 * All the best,
    Torsten
 *  [mupa](https://wordpress.org/support/users/mupa/)
 * (@mupa)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232548)
 * By the way, with RSS feed i don’t mean the feed of my own site. I’m using the
   RSS reader widget which comes with WordPress to show the last 10 headlines of
   a specific RSS feed.
    So i have a small box on the right side of all my sub sites
   which shows the last 10 headlines of for example [http://www.sport1.de/tennis/news.rss](http://www.sport1.de/tennis/news.rss).
 *  Plugin Support [Torsten Landsiedel](https://wordpress.org/support/users/zodiac1978/)
 * (@zodiac1978)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232549)
 * This sort of dynamic content inside the page cannot be excluded from Cachify,
   but if you delete the cache every hour the caching doesn’t make any sense anymore,
   I think …
 * All the best,
    Torsten
 *  [mupa](https://wordpress.org/support/users/mupa/)
 * (@mupa)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232551)
 * I have found a solution for this use case:
    If you have RSS content which needs
   to be updated frequently, then don’t let WordPress do the job. I now have created
   a RSS widget (there are tons of generators) and pasted it into the text widget
   from WordPress. The generated RSS widget has some javascript which does the update
   job itself. So now it doesn’t matter if the code is compressed or not.
 *  Plugin Support [Torsten Landsiedel](https://wordpress.org/support/users/zodiac1978/)
 * (@zodiac1978)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232552)
 * This looks like a great solution for this use case. Thanks for sharing!
 * All the best,
    Torsten
 *  Thread Starter [vojtechm](https://wordpress.org/support/users/vojtechm/)
 * (@vojtechm)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232553)
 * Hi,
 * sorry to bother again but this script really do nothing after few days of testing.
   I’ve put it into my functions.php (all scripts from it works ok). What did I 
   do wrong? This is the code I’ve put into end of functions.php file of my theme.
 *     ```
       if ( ! wp_next_scheduled( 'my_cachify_flush_cache' ) ) {
           wp_schedule_event( time(), 'daily', 'my_cachify_flush_cache' );
       }
   
       add_action( 'my_cachify_flush_cache', array( 'Cachify', 'flush_total_cache' ) );
       ```
   
 * It really drives me mad since I need to get this done.
 * Could you please check if script works properly?
 * Thank you.
    Br, Vojta
 *  [Pascal Birchler](https://wordpress.org/support/users/swissspidy/)
 * (@swissspidy)
 * [10 years ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232564)
 * Hey there
 * I just tested this snippet using the [WP Crontrol](https://wordpress.org/plugins/wp-crontrol/)
   plugin. When I put the snippet into the functions.php file of the theme, the 
   cron hook gets successfully registered, and when the action is being run, `Cachify::
   flush_total_cache()` is called as expected.
 * I recommend you to test it using WP Crontrol as well, as this plugin will show
   you when the cron job ran for the last time and allows you to run it manually
   as well. It could certainly be possible that cron itself isn’t working on your
   site, which this plugin will tell you.
 *  [Pascal Birchler](https://wordpress.org/support/users/swissspidy/)
 * (@swissspidy)
 * [10 years ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232565)
 * NB: If you want to flush the cache of all caching methods (DB, Memcached, APC)
   and no just the current method (which should suffice, but you never know), you
   can also use this:
 *     ```
       if ( ! wp_next_scheduled( 'my_cachify_flush_cache' ) ) {
       	wp_schedule_event( time(), 'daily', 'my_cachify_flush_cache' );
       }
       function my_cachify_flush_cache() {
       	if ( class_exists( 'Cachify' ) ) {
       		Cachify::flush_total_cache( true );
       	}
       }
       add_action( 'my_cachify_flush_cache', 'my_cachify_flush_cache' );
       ```
   
 * Again, this works like a charm on my local site running 4.5.
 *  Thread Starter [vojtechm](https://wordpress.org/support/users/vojtechm/)
 * (@vojtechm)
 * [10 years ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232567)
 * Hi,
 * this solved my issue!!! Thank you very much for your help 🙂
 * Br, Vojta

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘CRON cache flush’ is closed to new replies.

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

 * 13 replies
 * 4 participants
 * Last reply from: [vojtechm](https://wordpress.org/support/users/vojtechm/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/cron-cache-flush/#post-7232567)
 * Status: resolved