I'm working with magento EE that has full page caching feature. There is a block that is updated dynamically, but I can't seem to disable its caching. What I want to achieve ideally: disable caching only for particular block so it would be rendered again each time the page loads. Things I tried:
Include unsetData to layout file
<action method="unsetData"><key>cache_lifetime</key></action>
<action method="unsetData"><key>cache_tags</key></action>
Set function _saveCache to return false
protected function _saveCache($data, $id, $tags = array(), $lifetime = null) {
return false;
}
Set different values for cache_lifetime
public function __construct()
{
$this->addData(array(
‘cache_lifetime’ => 0,
‘cache_tags’ => array(Mage_Catalog_Model_Product::CACHE_TAG),
));
}
Perhaps I'm missing something in full page caching mechanics?
cache_lifetime must be set to null to disable cache for this block
Here is the solution for disabling FPC for a specific controller (could be extended to specific action as well).
First create an Observer to listen on the controller_action_predispatch event:
Then add the following to your config.xml file for the module. This goes in the section:
Now Magento will serve up your page every time and bypass FPC for the request.
And You can also refer: http://mikebywaters.wordpress.com/2011/12/14/disable-magento-full-page-cache-on-a-per-controller-basis/
Well, I found a couple of good posts and implement my caching with
etc/cache.xml
, that wraps my block with container object.My
cache.xml
:I used here as
block
the block that should not be cached, asname
name of block in my layout, and ascontainer
I've choose my container.Code for container:
Here I put
microtime()
function to identify block, but inside my module I used cookie variables related to my module. I believe that saves redundant reloading of a block when nothing was really changed.The thing that I didn't found in other tutorials is that I had to create layout variable and assign it to my block, otherwise I was getting only my block instead of whole page.