0

We're using CE Cache and need to schedule it to clear every day at 2am (or other time).

I've poked around and couldn't find anything in the configs to automate this, and am not finding any documentation on it, so assuming it is not built in to CE Cache.

3

CE-Cache for EE2 (i.e. CE-Cache 1.101) and for EE3 (i.e. CE-Cache 2.0.2) each have the ability to clear the cache in response to an 'ACT' call.

The action is registered in the EE Database as 'break_cache' and appears to require the submission of the CE-Cache "Secret" and the IDs of the channels that you want to break the cache for in a pipe-separated list.

From what I can tell you cannot run the ACT call if you have not specified a secret.

So it seems in theory all you need to do is find out the action number for the 'break_cache' call in your EE database and then set up a cron job to periodically issue a request to the appropriate URL.

You can get the ACT number dynamically using an exp:query call in your template, or by looking up the number in your DB and entering it as a hard-wired number. Then presumably you have a URL that looks a bit like:

https://domain.com?ACT=XX&secret=yoursecrethere&ids=id_1|id_2|id_3

What actually gets cleared then depends on what rules you have set for clearing those channels in your CP configuration.

Once you have this worked out, then you need to set up a cron job on your server to poll this URL at what ever interval you prefer.

N.B. This appears to be an undocumented feature for CE-Cache (at least I have not found such in documentation from a cursory scan of same) - so this guidance based on a quick scan of the add-on code itself. Accordingly E&OE.

HTH

1

CEcache has a config setting that lets you control the number of seconds before cached items are renewed. This won't clear all caches at once, rather cached files based on their timestamp. https://docs.causingeffect.com/expressionengine/ce-cache/user-guide/configuration.html

Another approach would get to get the clear cache URL's in the control panel (they usually have an ACT= value in the URL), then use CRON to trigger those URL's at 2am - not tested but that's the general idea.

2
  • We are indeed using the "for" attribute to clear the individual templates etc (which are often set at different intervals), and have left the default to 1 hour. But we need a way to bulk-clear everything at a specific time, regardless of time stamp etc. Appreciate the CRON info, will definitely look into that! Seems promising :) Thank you kindly! Aug 13 '20 at 17:27
  • No problem, I've never had need to do that but it's the first thing I'd look at. Depending on your CECache set up you might need to run a couple of CRON's to clear every last bit. Aug 14 '20 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.