1

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.

2

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>
| improve this answer | |
  • Good answer but DO NOT change files in base folder because they will be overwritten by the next Magento upgrade. Just add the changes in the local.xml from your theme folder: app/design/frontend/your-theme/default/layout/local.xml – Alain Banutz Feb 28 '17 at 18:58
1
<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/

| improve this answer | |
  • Didn't help. The documentation (github.com/nexcess/magento-turpentine/wiki/ESI_Cache_Policy) says: "private: one version per client is stored in cache (the session cookie identifies which client gets which cached version of the block)". Isn't this the direct opposite of what I need? I need to cache the block not by client, but by a page: front page keeps one version for every client, other pages keep their own version. – Victor Sergienko Aug 24 '15 at 18:01

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.