etc_cache: cache trying hard to be smart

When you have thousands of articles, processing the whole list (say, for creating a sitemap) can become time consuming. It is then a good idea (unless you publish an article every minute) to cache the processed result. Naturally, the cached block must be updated when some article is added/deleted. Most caching plugins trigger this update when the corresponding page is visited after the site update. This has, however, two inconveniences:

the first visitor has to wait while the expired block is processed and cached again;

every site modification, even irrelevant to the cached content, yields the cache update.

That’s what etc_cache is aimed to solve. The basic usage is

<txp:etc_cache id="heavycode">
<!-- heavy code -->
</txp:etc_cache>

The code will be processed and cached until the site is updated. On site update, the plugin will ping the url containing this block, triggering the cache refresh. Hence, the cache will always stay up to date, without penalizing site visitors.

You can be more specific with cache reset criteria. Say, if you need a block to be reset only if the article 3 is updated, edit (Extensions tab) the following fields of etc_cache table:

A positive (relative) value of time will indicate that the cache (even a fresh one) must be reset on site update. A negative value will not observe site updates. An absolute value like time='<txp:modified format="%F %T" gmt="1" /> +1 month' will mean “cache it if not modified since one month”.

Re: etc_cache: cache trying hard to be smart

Is there a way of disabling caching globally temporarily, for example via a prefs switch or in debugging* mode?

I’m currently doing flat theme updates to a site and have to clear the cache regularly. Disabling the plugin throws up missing tag errors. You have a $nolog global in the code but I can’t see where it’s actually used.

*Using debugging mode to disable caching would make things easy, but would one sacrifice being able to debug etc_cache at the same time?