I'm running Drupal 7.25 on my Ubuntu server. I have a process that is kicked off by user interaction (form) that needs to run in the background. I currently have cron.php being run every minute via crontab. I read this article:


Does running cron.php still clear cache in D7?

  • A lot of modules use "lightweight cron" which only do specified lightweight tasks if you have something that needs to be checked every minute. Check out the Scheduler module. – Beebee Jan 6 '14 at 17:24

Yes, running cron.php still clear cache, as running the cron will call system_cron which calls "cache_clear_all" method:

$cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
foreach ($cache_tables as $table) {
  cache_clear_all(NULL, $table);
  • Thanks! Now I can set back my crontab so I'm not killing my site every minute ;) – Ken J Jan 6 '14 at 16:57

If you take a look at system_cron(), you will see

$cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
foreach ($cache_tables as $table) {
  cache_clear_all(NULL, $table);

Reading the docs for cache_clear_all($cid, $bin):

$cid: If set, the cache ID or an array of cache IDs. Otherwise, all cache entries that can expire are deleted. The $wildcard argument will be ignored if set to NULL.

This means that a full cache clear won't be done, but entries that are older than their TTL are removed from the cache.

However, {cache_page} uses CACHE_TEMPORARY for the TTL (see drupal_page_set_cache(), so these will be removed each cron run. Though the code support it, I have never seen anything other that a -1 in the exipres column in {cache_page}, no matter what the TTLs on the performance settings are.

  • Everyone interested should read the comments at metaltoad.com/blog/…, search for the comment "This is incorrect. This call" by Moshe Weitzman. – Elijah Lynn Dec 30 '15 at 20:34
  • This answered my question as to why my cache wasnt expiring even with low values, without running cron.... – coderama Mar 9 '16 at 8:23

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.