Question

In my header.phtml, I have a front page-specific HTML (H1 tag) under $this->getIsHomePage() condition. I need this H1 to appear only on front page.

The problem is: under Turpentine, this H1 tag appears on every page. I believe it's because Turpentine caches the block for the whole site.

By default, turpentine_esi.xml has the following configuration for header block:

    <!--
    A default Magento site includes a logged in user's name in the welcome
    message and the number of items in the shopping cart so it must be
    cached per-client.
    -->
    <reference name="header">
        <action method="setEsiOptions">
            <params>
                <access>private</access>
                <flush_events>
                    <wishlist_item_save_after/>
                    <wishlist_item_delete_after/>
                    <sales_quote_save_after/>
                </flush_events>
            </params>
        </action>
    </reference>

I don't have the login info in the header template, so I believe I can just drop the header block from the configuration (or rather override it in local.xml).

The solution I can think of is: don't cache header block in Turpentine at all, cache it in the full page HTML. So I removed this piece from turpentine_esi.xml.

Problem is: the H1 block is still rendered on all the pages.

I have restarted varnish, php5-fpm, physically deleted Magento's var/cache, flushed blocks, ESI blocks and page HTML cache in admin... and I still see the wrong version of header template, with H1 on every page.

Another way, I tried to change the header caching options to public - this didn't help either:

    <reference name="header">
        <action method="setEsiOptions">
            <params>
                <access>public</access>
            </params>
        </action>
    </reference>

I'm using Magento 1.9.0.1.

Was it helpful?

Solution

In the end, I needed to override (remove) the header block from turpentine_esi.xml in app/design/frontend/base/default/layout/local.xml. My local.xml:

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="header">
            <action method="setEsiOptions">
            </action>
        </reference>

        <!-- We at Tahta.com.ua only need to cache the cart block. -->
        <reference name="top_cart_block">
            <action method="setEsiOptions">
                <params>
                    <access>private</access>
                    <flush_events>
                        <wishlist_item_save_after/>
                        <wishlist_item_delete_after/>
                        <sales_quote_save_after/>
                    </flush_events>
                </params>
            </action>
        </reference>

    </default>
</layout>

OTHER TIPS

<reference name="header">
 <action method="setEsiOptions">
    <params>
        <access>private</access>
    </params>
 </action>
</reference>

Also please refer this link https://rajeshganjeer.wordpress.com/2014/05/28/varnish-with-magento-terpentine/

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top