Disable/Bypass Magento Full Page Cache on single p

2019-02-02 18:52发布

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条回答
老娘就宠你
2楼-- · 2019-02-02 19:23

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楼-- · 2019-02-02 19:33

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楼-- · 2019-02-02 19:35

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.

查看更多
登录 后发表回答