0

I need to make my minicart not include in Magento's FPC. So, I've added below code to my layout's default.xml file.

<block class="Magento\Framework\View\Element\Template" name="custom.header" template="Magento_Theme::html/header.phtml" cacheable="false">
                    <arguments>
                        <argument name="target" xsi:type="string">contentarea</argument>
                        <argument name="label" translate="true" xsi:type="string">Skip to Content</argument>
                    </arguments>
                </block>

But, The problem is now header is included in all pages of website, And its make website slower, Like we have disabled cache from admin.

I've seen many questions regarding not to use cacheable="false".

Is there is any solution to make it possible ??

Thanks in Advance.

1

Using cacheable="false" will make your whole page uncacheable. See devDocs here. You can extend the block, add this to it's constructor :

protected function _construct()
{
     $this->addData(array(
        'cache_lifetime' => 0
     );
}
1

Try setting cacheable=false for the following block.

<block type="checkout/cart_minicart" name="minicart_head" template="checkout/cart/minicart.phtml" before="-">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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