We have a situation that the Magento cache is refreshed every night automatically. Afther this a script runs which visits every page to build the cache and every page will be fast. This works, however when someone is working in the admin (changing products, changing textpages etc.) the cache becomes invalid and I have to visit the product page again to build the cache.

My question is, when does the cache become invalid and how can we prevent this. Thanks in advance.


Well...it's normal to invalidate the cache when you change something.
But if you want to know...
All models extend Mage_Core_Model_Abstract, including the product model and the cms page model.
This Mage_Core_Model_Abstract class contains a method called _afterSave which is called each time you save an entity. (obviously).
This _afterSave method calls cleanModelCache which takes all cache entries with specific tags (returned by the method getCacheTags from each model) and clears those entries.

If you don't want the cache to be cleared for a model, just rewrite the method cleanModelCache and make it do nothing, or getCacheTags and make it return an empty array. but I strongly advice against this.
Users will see outdated information.

  • Hi Marius, thanks for your detailed answer! I get that when I change product A, the cache of product A is cleared. However, when some products are added and some pages are changed, the cache of all the products is cleared. So actually I was searching for de admin action which causes the cache clearing of all the products. – Benidorm Jul 19 '16 at 14:15

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.