在我的 header.phtml, ,我有一个特定于首页的 HTML (H1 标签)下 $this->getIsHomePage() 健康)状况。我需要这个 H1 仅出现在首页。

问题是:在松节油下,这 H1 标签出现在每个页面上。我相信这是因为松节油缓存了整个站点的块。

默认情况下, turpentine_esi.xml 有以下配置 header 堵塞:

    <!--
    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>

我的标题模板中没有登录信息,所以我相信我可以删除 header 阻止配置(或者更确切地说,在 local.xml).

我能想到的解决方案是:不缓存 header 根本不使用松节油,将其缓存在整个页面 HTML 中。所以我把这一段从 turpentine_esi.xml.

问题是:H1 块仍然呈现在所有页面上。

我已经重新启动了varnish,php5-fpm,物理删除了Magento的 var/cache, 、刷新块、ESI 块和管理中的页面 HTML 缓存...我仍然看到标题模板的错误版本 H1 在每一页上。

另一种方式,我尝试改变 header 缓存选项 public - 这也没有帮助:

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

我正在使用 Magento 1.9.0.1。

有帮助吗?

解决方案

最后,我需要覆盖(删除) header 阻止来自 turpentine_esi.xmlapp/design/frontend/base/default/layout/local.xml. 。我的 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>

其他提示

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

另请参考此链接 https://rajeshganjeer.wordpress.com/2014/05/28/varnish-with-magento-terpentine/

许可以下: CC-BY-SA归因
scroll top