Magento 1 – How to Disable Cache for Particular Section or Block

blockscachece-1.6.2.0magento-1

I have developed a top bar cart functionality for store front that displays latest three products added to the cart this works great when cache is disabled but when i enable the cache it showing weird subtotal in top cart and weird products in cart.

This make me sad :'(

I know this is happening because of cache. Is there anything that I can disable the cache for this section only? I have tried disabling the block html cache and check now this was working great but I found the category flat is having unspecified issues when block HTML is disabled.

Best Answer

You can try

    <reference name="needed block">
        <action method="setCacheLifetime"><s>null</s></action>
    </reference>

or

    <reference name="needed block">
        <action method="setCacheLifetime" />
    </reference>

to set it to null.

But probably it is better to use ajax.

There is a good article about null or 0 meaning http://blog.kyp.fr/make-a-clean-sweep-of-commons-magento-cache_lifetime-workarounds-usage-in-cache-block-policy/ (link is broken)