I can't find any specific documentation explaining how the default caching mechanism in Drupal 7 works and when does it clear caches automatically. From my own testing, I can state the following:

  • Cache is cleared when any content is added
  • Cache is cleared when any content is updated
  • Cache is NOT cleared when content is deleted!!! (Check my comment below for update).

Where can I find documentation to approve the above and also learn a little more about this topic? Any other cases where cache is auto cleared?

Details: the above results are based on turning on both "Cache pages for anonymous users" and "Cache blocks" and setting "Minimum cache lifetime" and "Expiration of cached pages" to none.

  • 1
    Drupal caches content in many levels - menus, forms, blocks, filters, etc. Also, how did you know that caches are cleared ?
    – AKS
    Commented Nov 27, 2012 at 17:45
  • I confirmed that caches are cleared by checking the cache_page and other cache_* tables in the database. The behavior I described above mostly applies to the page cache which is the most important to my case (or maybe everywhere). Drupal caching on many levels is exactly why I'm looking for more info/documentation on the subject.
    – Mario Awad
    Commented Nov 28, 2012 at 17:34
  • UPDATE: Cache was not cleared when content was deleted in previous Drupal versions. The current version Drupal 7.31 (and possibly a few versions before it) no longer have this issue, which makes more sense. Hope this helps someone. Cheers.
    – Mario Awad
    Commented Sep 8, 2014 at 8:19

1 Answer 1


To find out all events when page and block cache is cleared - you can search through all modules for using of cache_clear_all() function.

Here is brief list of such events in Drupal core.

  1. Any content is created or updated (nodes, taxonomy terms, comments, etc)
  2. Content permissions are updated.
  3. Block is created or updated.
  4. Vocabulary created, edited or deleted.
  5. Any settings form in admin back-end is submitted (those forms that use system_settings_form()).
  6. User account is created, updated or canceled.

As you see page and block cache is not cleared automatically when any content is deleted.

  • Yes, this is what I started doing before posting the question but, does cache clearing only happen using cache_clear_all? (I'm sure I came across at least one other function that can be used to clear cache). Also, there must be a better way to get this info (a document or a diagram) rather than just scan the code. Thanks for the help and your input.
    – Mario Awad
    Commented Nov 28, 2012 at 17:35
  • Please, provide name of function that also used for clearing cache. And i think that studying code is the better that any documentation or diagram:) Commented Nov 29, 2012 at 9:13
  • I searched for it again and here it is: drupal_flush_all_caches (works in Drupal 6 and 7). Definitely studying the code is a decent option, but it's not enough especially when we don't have a list of all ways the cache can be cleared.
    – Mario Awad
    Commented Nov 29, 2012 at 10:31
  • 2
    drupal_flush_all_caches() is used when you enable module or run update.php or clear the whole cache manually. Commented Nov 29, 2012 at 11:41
  • Thank you for your answer and comments Eugene. I will leave this question open hoping that someone else has links official documentation about this. Until then, I'm diving into code. Cheers.
    – Mario Awad
    Commented Nov 29, 2012 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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