• Resolved ahnurbd

    (@ahnurbd)


    Hi
    Thanks for a great plugin. I use this along with Fluxstore app to cache rest calls for my mobile app. I need to clear the cache with a corn job (which I can manually do by pressing the “Clear Rest Cache” on WP admin bar).
    For running a custom cron job, I use WP control which lets me execute PHP code at a specific time and intervals.
    I’ve tried this but couldn’t really understand.
    Lets assume that I’m calling custom function defined in my functions.php file named my_cron_job().
    How can I clean all the cache (just like clicking the “Clear Rest Cache” button) in this function?
    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ahnurbd

    (@ahnurbd)

    Tried this in a cron job and everything seems to work for me. (deletes statistics though)

    
    \WP_Rest_Cache_Plugin\Includes\Caching\Caching::get_instance()->clear_caches(true);
    
    Plugin Author Richard Korthuis

    (@rockfire)

    Hi @ahnurbd

    Thank you for using our plugin!

    You can indeed use the function you mentioned. If you don’t want to delete statistics, simply change the parameter from true to false.

    Also we just released a new version of our plugin which now includes a WP CLI command to flush caches: wp wp-rest-cache flush. So you could also use that in a cron job.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Clean cache via cron job’ is closed to new replies.