Magento (How to fix): One or more of the Cache Types are invalidated: Blocks HTML output.

Some time has passed since I wrote original version of this article, Magento was at 1.5. these days…

Now, almost 2 years later I have decided to revamp the article since lot’s of feedback is gathered…

For that purpose, I have wrote small extension for it that you can find here:
https://github.com/tomasinchoo/Inchoo_InvalidatedBlockCacheFix/tags

I would like to thank all of you, especially people that gave suggestions in order to improve it.

Main difference is that it is done through observer and the code is wrapped up in extension for easier use.

Keep in mind that this extension is created for purposes of blog article at inchoo.net and as such can only be used as proof of concept. If you find it helpful in order to learn Magento, that is great, but be careful if you plan to use it in production environment even though I do 🙂

Some sites can’t afford to clean block cache on every product edit, so please keep that in mind.

Thanks, and looking forward to your feedback!

You made it all the way down here so you must have enjoyed this post! You may also like:

Using Redis cache backend and session storage in Magento Marko Martinovic
Marko Martinovic, | 43

Using Redis cache backend and session storage in Magento

Super easy universal Magento cache extension Srdjan Stojiljkovic
Srdjan Stojiljkovic, | 14

Super easy universal Magento cache extension

Magento block caching Ivan Weiler
, | 33

Magento block caching

83 comments

  1. Beside I respect this side and I got some valuable information in the past:
    This approach to the problem is very funny, it is like your wife cheat on you and your solution is to give her a shower.

    If you are saving one product and you have to refresh all the cache because of that, this is not a solution because you are wasting 90% of the cache for just 1 product:
    – If the cache is invalidated it means it will not be used till you refresh it.
    – if you refresh it you loose all the previous cache stored (because refresh in magento means delete )

    A serious approach would be:
    – to find out why the whole cache is invalidated when you save a product ? ( this is for sure a core bug )
    – fix this behavior so that only the cache related to the product you saved is invalidated/refreshed.

    This is what I would call a solution, not hide the alarm and reset the whole thing every time.

    1. Thanks for comment. You are right. Yet, this article is like 7 years old. Before Magento version mentioned in article, Magento didn’t invalidate cache at all (at product save) even though it should have. This is not a bug at all. This is merely notification about current state of Magento cache. That being said… At that point we were working on daily deal sites (you probably remember those). and this was requirement (yes, we used only 1 product active at any given time). Article was created just as proof of concept.(as it was mentioned), and hence the notice that some sites can’t afford clearing the cache on every product save. My bad I didn’t state the obvious: “It clears block cache, maybe it is not good idea for everyone”. 🙂 Anyway, there are people using this so I couldn’t just delete it, but I’ll go check it and see if I can make it more clear on github what is it all about…

  2. “I have decided to revamp the article” means you’re going to post a link to the module code? What happened to the original article? I’d like to actually learn about the issue and how you went about deciding how to solve it.

  3. I’m seeing that the cache is refreshed properly, but for some reason the warning is still appearing, even with the content up to date. Is this happening for anyone else or is it just me?

    1. Hi Dave, this is happening for me too on 1.9.0.1. Did you find anything out? This is the behaviour I see:

      When triggered by event controller_action_postdispatch_adminhtml_catalog_product_save in adminhtml scope (i.e. manual product save in admin interface) then the cache is cleaned and the warning disappears.

      When triggered by event catalog_product_save_commit_after in global scope, the cache appears to be get cleaned but the warning persists. I need to use this because our products are updated by API.

      When triggered by a cron job, the cache appears to be cleaned but the warning persists. I tried this as a workaround.

      I’ve dug around the core code a lot and I can’t figure a reason why this behaviour is happening.

  4. Terrific work! That is the type of info that should be shared around the internet.
    Shame on Google for now not positioning this post upper!
    Come on

    over and consult with my website . Thank you

    =)

  5. @Fulvio … Hm… where exactly did you read that it works only for US?
    https://github.com/tomasinchoo/Inchoo_InvalidatedBlockCacheFix/blob/master/README.md

    Maybe you read that one on this (OTHER) extension: https://github.com/tomasinchoo/Inchoo_USDisableRegions

    Well, in that case I’m afraid you should try some other extension like this one: http://www.magentocommerce.com/magento-connect/remove-or-change-displayed-states-and-regions-1964.html

    My version was created as part of the project on which client had no interest in shipping to any other country than USA so that save us some time and some cost to the client 😉

  6. Hi Tomas i tried to install your app but it gave me some problem, you write in the README file:
    ” ….It works only for US….. ”
    why only for US they look better than european or oceanian african etc… ? 😉

  7. @darren You mean tutorial for copy-paste? Please check my previous comment: “@Casper – Just unpack it and copy to your site’s root directory…”

  8. I am pretty new with Magento. How do I even “install” this extension?

    Thanks so much in advance!

  9. We are a gaggle of volunteers and starting a new scheme in our community.
    Your site provided us with helpful info to work on.
    You’ve done a formidable job and our whole community might be thankful to you.

  10. Fantastic goods from you, man. I have understand
    your stuff previous to and you’re just extremely excellent. I really like what you have acquired here, certainly like what you’re saying and the way in which you say it.
    You make it enjoyable and you still care for to keep it sensible.
    I can’t wait to read far more from you. This is really a terrific website.

  11. Thank you for sharing superb informations. Your website is very cool.
    I’m impressed by the details that you have on this web site. It reveals how nicely you

    understand this subject. Bookmarked this website page, will come back for extra articles.

    You, my pal, ROCK! I found just the information I already searched all over the place

    and simply could not come across. What an ideal website.

  12. Hi Robert,

    Well… you are right … singleton is not needed since if you don’t specify otherwise, you will always get singleton 🙂

  13. Already created this little extension myself, a few differences, I made a yes/no enable feature for the backend, in yours you have singleton inside the observer where as mine does not.
    Why should this be needed?

    Rob.

  14. @Alex I could have added it, however, it is ALWAYS invalidated, even if you save product with no NEW data, however I don’t see what can it break, so I will add it as soon as possible 🙂 Thanks for feedback!

  15. Why dont you check at least if cache is invalidated before flushing it? Something like
    $invalidateTypes = Mage::app()->getCacheInstance()->getInvalidatedTypes();

    if (!empty($invalidateTypes[‘block_html’])) {…

  16. Hi everyone, I would just like to inform you that there is revamped version of this article if you are interested! 😉

  17. @Lewis
    Not really. Magento Cron runs on my server but the cache block still gets invalid. (1.7.0.2)
    Fix from travis worked fine. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.