Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
1  
Drupal caches content in many levels - menus, forms, blocks, filters, etc. Also, how did you know that caches are cleared ? –  Ayesh K Nov 27 '12 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 Nov 28 '12 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 Sep 8 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.

share|improve this answer
    
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 Nov 28 '12 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:) –  Eugene Fidelin Nov 29 '12 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 Nov 29 '12 at 10:31
2  
drupal_flush_all_caches() is used when you enable module or run update.php or clear the whole cache manually. –  Eugene Fidelin Nov 29 '12 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 Nov 29 '12 at 15:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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