11

How can I disable or bypass FPC for a single page? I don't want to use hole-punching as there are several blocks on the page that I need to be dynamic and I would rather modify one config/class to specify that the entire page should not be cached (similar to the behavior of checkout).

My understanding of FPC was that it was not used for "session users" (logged in, added to cart, etc...). However, I'm seeing FPC affect pages when a user is logged in. If I disable FPC, then the page works as desired.

3 Answers 3

18

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:

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

    // Check to see if $action is a Product controller
    if ($action instanceof Mage_Catalog_ProductController) {
        $cache = Mage::app()->getCacheInstance();

        // Tell Magento to 'ban' the use of FPC for this request
        $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>
        <observers>
            <YOUR_UNIQUE_IDENTIFIER>
                <class>YOURMODULE/observer</class>
                <method>processPreDispatch</method>
            </YOUR_UNIQUE_IDENTIFIER>
        </observers>
    </controller_action_predispatch>
</events>

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

4
  • what if I want to use it for CMS page? I can use the xml part in update xml of CMS page but I don't knpw what to write in class tag
    – Nickool
    Jan 30, 2015 at 0:27
  • Thx, I digged around the code of FPC, so far this look the best approach. The interesting entry point could be Mage_PageCache_Model_Processor but it cannot be override, because it is initialized with new .. ( at least at the beginning ... second time a sigleton is used ... )
    – WonderLand
    Oct 29, 2015 at 5:25
  • can someone tell me, what should I write instead of "your unique identifier"? thx :) Feb 9, 2016 at 7:56
  • @Chester literally_anything_you_want_as_long_as_it_is_unique. Though typically you should at least prefix it with the shortname of your module. Feb 10, 2016 at 15:28
5

Just got done wrestling with Magento EE FPC not displaying core messages on cached CMS pages. Core messages worked fine on cache category and product pages but not CMS pages. I found by passing a certain parameter to a page you can force that pages to be generated instead of server out of the cache.

found in: app/code/core/Enterprise/PageCache/Model/Processor/Default.php

/**
 * Disable cache for url with next GET params
 *
 * @var array
 */
protected $_noCacheGetParams = array('___store', '___from_store');

So it is possible to make a link that has a HTTP GET query string that would bypass the FPC.

http://www.domain.com/?___store

This helped solve a problem I was having were a plugin was redirecting to a referring url with a session message but if the referrer was a CMS page the message would not be displayed until a non-CMS page was viewed.

3
  • 1
    Stores with hundreds of thousands of products will experience heavy server loads if FPC is bypassed, which makes this a potential vector for DDOS attacks. Is there a way to prevent this behavior?
    – Alex
    Oct 16, 2012 at 8:16
  • Agree this could be a potential issue for large catalogs. Looks like a custom module to alter this behavior would be the way.
    – Ian at SSU
    Dec 3, 2012 at 4:31
  • Generally when dealing with EE FPC caching messages it's because you're probably trying to output them with getGroupedHtml(). You need to use just toHtml() in order to make sure that the Enterprise hold punching for messaging works correctly.
    – CVEEP
    Jun 26, 2013 at 18:40
0

Magento's FPC is one complicated beast.

I've overcome this using the following tutorial:

http://oggettoweb.com/blog/customizations-compatible-magento-full-page-cache/

This might be what you're referring to as "Hole Punching", but it's the only way I've found to overcome it.

3
  • Yes, that is hole punching. I tried following the instructions from the link, but I keep getting: "Fatal error: Maximum function nesting level of '200' reached, aborting!" (the number doesn't matter. I've tried increasing the maximum and it just keeps hitting it) when FPC is enabled. Looks like there is a loop gone wild somewhere. If I turn off FPC, everything works fine again. Dec 9, 2011 at 0:08
  • 2
    That's why single link answers are bad. The URL is dead, your answer is useless.
    – user487772
    Oct 5, 2014 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.