• Resolved vermaakpetrus

    (@vermaakpetrus)


    Hi there,

    Is it possible to schedule a periodic clear cache? Is it possible to do with an internal WordPress Cron?

    If this is possible with an external cron, how do we set the time that the cron must run? Unfortunately, our cron can only set the frequency it must run, not the time it must run as well.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Is it possible to schedule a periodic clear cache? Is it possible to do with an internal WordPress Cron?

    Yes absolutely. Inside the plugin settings > Others Tab
    You will bind the URL where you need to run the CRON job to purge the cache via CRON job.

    If this is possible with an external cron, how do we set the time that the cron must run?

    – You can run a server level CRON job on the URL.

    Thread Starter vermaakpetrus

    (@vermaakpetrus)

    Awesome!!! Just what we were looking for! Is there an option to schedule clear cache of single pages?

    Plugin Contributor iSaumya

    (@isaumya)

    Is there an option to schedule clear cache of single pages?

    – No. There is no predefined CRON URL for single page, but there are filters (documented in the FAQ section within the plugin settings) that can be used for clearing cache for single pages. Look at the FAQ section inside the plugin settings.

    Can this idea of flushing the cache on a schedule not be achieved by editing the “Cloudflare cache-control max-age” field in the settings > cache tab? This is set to 1 year by default but if you change it to 86400 would this force Cloudflare to refresh its cache once a day?

    Plugin Contributor iSaumya

    (@isaumya)

    So, the s-maxage that you set which is by default 1 year tells Cloudflare how long you intend to keep the item in cache but that does not mean that CF will always honor it and keep it in cache even if there is no traffic to it. You can reduce the time and check if that works for you.
    I will suggest you to read this article: https://acnam.com/untold-truths-of-cloudflare-cdn/ to understand deeply how CF caching is working behind the scene.

    Thanks for the explanation.

    I see the FAQ page notes that it’s possible to purge the cache for certain pages using the following PHP command:

    do_action("swcfpc_purge_cache", array("https://example.com/some-page/", "https://example.com/other-page/"));

    But how would you call this from a Cron job? Or is there a way to get WordPress to add this into its own scheduled WP-Cron events so that it was called once a day?

    Plugin Contributor iSaumya

    (@isaumya)

    Yes you can try that

    Just in case anyone is interested… I was able to schedule page-specific cache purges by adding a call to the “swcfpc_purge_cache” function via a plugin called WP Control. This let me create a new “php code” item (that simply contained the do_action code shown above) and assign a repeat schedule for the call. Seems to be working perfectly.

    Thread Starter vermaakpetrus

    (@vermaakpetrus)

    @livingstonescreative
    Thank you so much for giving the feedback! That is wonderful!!! Can I please ask you to record a video or write the steps on how to reproduce? I’m not a developer, just an enthusiastic user lol! I would love to use your method! I am sure everyone else will also benefit!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Schedule Clear Cache’ is closed to new replies.