I have the following cache settings on the performance page

enter image description here

I have visited a few pages as anonymous user and made sure that they are being cached. Now I log in as admin in a different browser and edit a node. The moment I do this I see that Anonymous Page Cache for all the pages are cleared.

This seems counter intuitive and render caching useless for sites with high content editions.

  • 1
    Note : I know the answer and the reason why this is happening. It took me a little while to figure this out. So I am posting this question. I have added an answer. If I find any better answers I will accept that as the answer :)
    – Gokul N K
    Commented Jan 18, 2014 at 19:36

1 Answer 1


Whenever I edit a node all my page caches are cleared.

As per the design : This behavior is intended behavior and works as per the design. If you look at the node_form_submit() node submit handler function within the node module you will notice that there is a cache_clear_all() As the comment in the line above the function call reads it clears the page and blocks cache as expected.

Reason for clearing all the caches: When a node is created/updated there can be many pages in the site which are dependent on the current node in question. It is next to impossible/very difficult identify all the dependencies and clear the caches only for those pages. For this particular reason, to make sure that no stale data is served to the end user drupal by default clears all the caches.

Work Around :

Approach 1 : Since node_form_submit is form submit handler you could just implement a hook_form_alter() and change the submit handler to your own function which can omit cache_clear_all() function call.

Approach 2 : Set Minimum Cache Life Time to a high value. (By doing this you are asking Drupal not to clear caches if they are not older than the specified Minimum Cache Life time. So now if you edit a node, the changes will not be visible immediately. Your changes will only be visible when time elapsed is greater than Minimum Cache Life time and next general cache wipe has occured.)

Once you have set the Minimum Cache Life Time you can use Expire module to implement your custom logic for Invalidating a cache. You can have settings such that whenever a node is edited drupal can clear the cache for that particular page and all the listing pages.

EDIT(After @MPDs comment) : If you are using a reverse proxy server then you might need to consider setting the Expiration of cached pages to an appropriate value and probably consider using purge module.

Futher Reading : Difference between Minimum Cache Lifetime and Expiration of Cached Pages value.

  • 1
    Did you test approach 2? I don't recall ever seeing the min cache time affect the TTL in {cache_page}, just the TTL in the HTTP headers.
    – mpdonadio
    Commented Jan 18, 2014 at 22:34
  • 3
    BTW, good self-answer.
    – mpdonadio
    Commented Jan 18, 2014 at 22:35
  • @MPD I verified that. If you look at the function clear cache.inc file (this function is in turn used cache clear all) you will notice if condition if (variable_get('cache_lifetime', 0)) { so the value is being used even for the cache clearing logic. And more-over what you are referring to is actually the outcome of "Expiration of Cache Pages" which handles the expiration of External caches including Browser :)
    – Gokul N K
    Commented Jan 19, 2014 at 7:14

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.