0

For each template in its Settings, we have Enable Caching? and Refresh Interval. I want to enable caching, but since my content is pretty set, want it to serve cache forever. (At least until the "clear cache" events happen or I manually flush cache.) Does leaving the Refresh Interval to blank do this? Or should I use a really high number? Using EE 4.3.4.

2

You can set the template refresh to a really high number (e.g. 14400 minutes which is 10 days), or you can change to using a static cache - for example the one that is built in to the stash add-on.

The possible advantage of keeping the EE4 cache with very high numbers is that it works, that it is easy to implement, and that you get (fairly crude) cache-busting built in. However basically if you touch anything to do with templates (and if you have it set so entries) EE will kill the entire cache - so if you do ever change an entry it will automatically clear / reset the cache (which might be helpful). But on an active site this means almost certainly you won't be able to keep a cache for much of the time...

There are two kinds of caching built into Stash:

  • One which is a bit like the EE one - you can cache within pages, whole pages, and leave bits of pages uncached. It too works, is quite a lot more work to setup (you have to add tags to each template) and unless you buy the Mustash add-on you get no cache-busting control at all (other than EE style "nuke the entire cache").

  • The other is a static cache - which builds a set of html snapshots of your pages as they are served (indexed on the URL pattern): it uses a modified .htaccess file and if a URL request matches a page already in the cache it simply sends back that HTML, not needing to even wake EE up. The upside of this is that it is very fast (as no EE type stuff is required), but the downside is it makes it harder to include dynamic elements in your pages (it is an 'all or nothing' option - so if you want interactive elements they have to be included as AJAX type stuff on the page). The Mustash add-on provides some cache-busting options, and you can actually just manage the cache manually (the HTML files are stored with meaningful names in a standard hierarchical folder structure that matches your website structure).

If your site tolerates it, I would suggest you check out the static cache option. Default for both options above is file based caching, but both support other caching schemes if such are available to you.

HTH

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.