1

Just want to confirm when a node is updated, the update operation clears the complete cache table or the updated node related cache contents. Is this right?

2
  • 1
    Please try to keep to one question per question. Also, block quotes should only be used for quotes, and not for question body content :-) – Chapabu Sep 11 '13 at 11:15
  • I am not sure why this question was Down-voted. Also I felt that @Molots answer is not complete and could be a little misleading to users who are new to Drupal and don't have enough knowledge about code. So adding a new answer. – Gokul N K Jan 23 '14 at 8:21
3

There is only one line about clearing cache in node_save():

// Clear the static loading cache.
entity_get_controller('node')->resetCache(array($node->nid));

It only resets entity-related cache. Caches related to another nodes, caches like boost and so on are left untouched, unless specifically cleared by other module's actions in node or entity saving hooks.

2
  • node_form_submit() is also run which actually clears the caches. I have covered the details in my answer drupal.stackexchange.com/a/100836/4876 – Gokul N K Jan 29 '14 at 11:51
  • @GokulNK Good catch. But only for node updates that happen via Drupal's default GUI. It's not the only way. To be honest, I'm not even sure if it is the way I use the most now. (+1 on your answer) – Mołot Apr 17 '15 at 16:44
2

Short Answer : Yes, it does.

Long Answer : Function node_form_submit from the file node_form_submit also gets called when you edit or add a node. The last line in this function is cache_clear_all. This function deletes all the entries form page and block cache bins and prunes the other cache bins.

The reason that cache_clear_all is moved from node_save() to node_form_submit is so that you could just change the form submit handler for this form and change the cache clearing logic if you want to.

A suggested approach would be to increase Minimum Cache Lifetime value from the performance page and then use the Expires which helps you handle your cache clearning(Invalidation) logic.

Detailed Explanation : Whenever I edit/update a node all the page caches for anonymous user are lost

1
  • 1
    thanks Gokul I will need sometime to digest it! I will check the api's, thanks again :) – arpitr Jan 23 '14 at 9:25

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.