4

I've just configured correctly the Varnish cache, finally, but now I ran into some issues...

I've notices, at the moment one important error and can't get to fix it.

The thing is that the Mini Cart (in my header) is beeing cached and displayes wrong information when accessed by another visitor.

How can I disable the mini cart caching??

I tryed modyfing the checkout.xml like this:

<!-- Mage_Checkout -->
<reference name="top.links">
    <block type="checkout/links" name="checkout_cart_link">
        <action method="addCartLink"></action>
        <action method="addCheckoutLink"></action>
        <action method="setEsiOptions">
            <params>
                <method>ajax</method>
                <access>private</access>
            </params>
        </action>
    </block>
</reference>

<reference name="header">
    <block type="checkout/cart_minicart" name="minicart_head" template="checkout/cart/minicart.phtml" before="-">
        <block type="checkout/cart_sidebar" name="minicart_content" template="checkout/cart/minicart/items.phtml">
            <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/cart/minicart/default.phtml</template></action>
            <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/minicart/default.phtml</template></action>
            <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/minicart/default.phtml</template></action>
            <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/minicart/default.phtml</template></action>
            <action method="setEsiOptions">
                <params>
                    <method>ajax</method>
                    <access>private</access>
                </params>
            </action>
            <block type="core/text_list" name="cart_sidebar.cart_promotion" as="cart_promotion" translate="label" module="checkout">
                <label>Mini-cart promotion block</label>
            </block>
            <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
                <label>Shopping Cart Sidebar Extra Actions</label>
            </block>
        </block>
    </block>
</reference>

By setting the ESI Options, but it didn't help,

Any ideas?

UPDATE

I've managed to retrieve the cart items, by adding this to the local.xml:

<default>
        <reference name="minicart_head">
            <action method="setEsiOptions">
                <params>
                    <access>private</access>
                    <ttl>0</ttl>
                    <method>ajax</method>
                </params>
            </action>
        </reference>
    </default>

But still having an issue with the counter, it's not beeing updated, any help, please?

  • so header excluded from cache or not? other blocks cache working? – user2857 Jan 16 '15 at 21:30
  • No, the header is cached, I thought about it, should I ESI comment the whole header? I would like to cache as mich as posible to get better site performance. Thanks @ADM – Artur Rain Jan 18 '15 at 22:54
  • 1
    Remember that ESI is expensive, you should exclude as few separate blocks of content as possible as each time you do a separate request must be sent to the backend (Magento) for the dynamic content. After just a very few ESI requests you are going to have pretty much lost the benefit of the Varnish cache. I would suggest you go with AJAX to update dynamic content instead. – Jonathan Hussey Jan 27 '15 at 16:20
2

I would try it without the <method>ajax</method> And add a flush event.

I copied this from a working customer's .../layout/local.xml:

    <reference name="cart_sidebar">
        <action method="setEsiOptions">
            <params>
                <access>private</access>
                <flush_events>
                    <sales_quote_save_after/>
                </flush_events>
            </params>
        </action>
    </reference>

Hope this helps.

  • 1
    thank you for your input. I had exactly the same issue and was able to fix it with your answer. Note: my header was not cached. – DarkCowboy Jun 15 '17 at 13:47

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.