Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 302494

Page and block caches are cleared the same way on cron as on content change

$
0
0

For more background, see http://www.metaltoad.com/blog/how-drupals-cron-killing-you-your-sleep-si..., which was written for D6, but the same problem exists in D7. Here's a summary:

  • system_cron() calls cache_clear_all(NULL, $table) for a bunch of tables, including 'cache_page'.
  • comment_form_submit(), node_form_submit() and a bunch of other functions call cache_clear_all() with no arguments, which results in cache_clear_all(NULL, 'cache_page') being called.
  • Records in cache_page have the expire field set to CACHE_TEMPORARY, because that's what drupal_page_set_cache() sets it to.
  • The default class that implements the 'cache_page' cache bin is DrupalDatabaseCache, whose clear() method when NULL is passed as $cid deletes all records with an expire of CACHE_TEMPORARY.
  • There is a cache_lifetime system variable, settable on the admin/config/performance page, that can be used to ensure that DrupalDatabaseCache::clear() doesn't run more than once within the corresponding interval, regardless of how often cron runs or website content gets changed.

This setup doesn't make sense to me. If I setup cron.php to run once an hour, why should my page cache be emptied each hour? Maybe I have a site whose content is only changed once per week on average: why should my page cache be emptied on cron at all? And while, yes, I can tune the cache_lifetime variable to be longer than my cron interval, doing so also means that when content is changed (i.e., a node or comment form is submitted), then my page cache really is stale for up to cache_lifetime.

And while, yes, I can override DrupalDatabaseCache with some other class, I'm not sure that helps, since I don't think it would have any way to distinguish whether clear() was called due to a node/comment submit or to a cron run.

Does anyone have thoughts on this? Knowledge of why system_cron() clears caches at all?

Related issues:
#1279654: Page cache is CACHE_TEMPORARY and does not honor cache_lifetime


Viewing all articles
Browse latest Browse all 302494

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>