Bypass Magento Full Page Cache on Single Page

You don't want to use hole-punching as there are several blocks on the page that have to be dynamic

Posted on April 6, 2016 in Magento

Here is the solution for disabling FPC for a specific controller by listen on the controller_action_predispatch event:


public function processPreDispatch(Varien_Event_Observer $observer) {
    $action = $observer->getEvent()->getControllerAction();

    if($action instanceof Mage_Catalog_ProductController) {
        $cache = Mage::app()->getCacheInstance();
        $cache->banUse('full_page');
    }
}

Then add the following to your config.xml file for the module. This goes in the <frontend> section:


<events>
    <controller_action_predispatch>
        <observer>
             <Unique_Identitfier>
                  <class>YOURMODULE/observer</class>
                  <method>processPreDispatch</method>
             </Uniuque_Identifier>
        </observer>
    </controller_action_predispatch>
</events>

Now Magento will server up your page every time and bypass FPC for the request.


comments powered by Disqus