【问题标题】:esi tag not working on laravel applicationesi 标签在 laravel 应用程序上不起作用
【发布时间】:2016-08-02 04:53:40
【问题描述】:

您好,我有以下问题。我有一个运行 laravel 5.1 的网站,为了使该网站可供许多用户使用,并获得更快的加载时间,我使用了 Varnish4。我的varnish vlc文件如下。

backend default {
    .host = "127.0.0.1";
    .port = "80";
}

sub vcl_recv {
    # Happens before we check if we have this in cache already.
    #
    # Typically you clean up the request here, removing cookies you don't need,
    # rewriting the request, etc.    
    unset req.http.Cookie;
}

sub vcl_backend_response {
    unset beresp.http.Set-Cookie;
    set beresp.do_esi = true;
    set beresp.ttl = 1m;
    return(deliver);
}

如您所见,我为所有请求启用了 esi processign(不是最佳做法,但我正在努力使事情正常进行),并删除 vcl_recv 子例程中的所有 cookie。

现在,我有一个带有 esi:include 块的刀片模板,如下所示:

<esi:remove>
    NO ESI SUPPORT
    <script>window.load_hot = true;</script>
</esi:remove>
<!--esi
    <p>The full text of the license: 
         <esi:include src="http://localhost/date.php" />
    </p>
-->

esi include 标签上的路由工作正常并返回预期的输出。 Varnish 系统按预期解析 ESI 块,因为未显示 fallback(show NO ESI SUPPORT) 消息。

那么,这段代码有什么问题呢?

【问题讨论】:

    标签: php caching laravel-5 varnish varnish-vcl


    【解决方案1】:

    esi:include 标签只接受路径,而不是带有协议和主机名等的完整 URL,例如

    <esi:include src="/cgi-bin/date.cgi"/>
    

    见:https://www.varnish-cache.org/docs/4.1/users-guide/esi.html

    【讨论】:

    • 很抱歉,这不是问题所在。检查我的答案,它在 esi:include 标记上具有绝对 url
    【解决方案2】:

    解决了。

    出于某种原因:

    <esi:remove>
        NO ESI SUPPORT
        <script>window.load_hot = true;</script>
    </esi:remove>
    <!--esi
        <p>The full text of the license: 
             <esi:include src="http://localhost/date.php" />
        </p>
    -->
    

    由于标签而无法正常工作。

    这样去掉标签后:

    <esi:remove>
        NO ESI SUPPORT
        <script>window.load_hot = true;</script>
    </esi:remove>
    
    <p>The full text of the license: 
             <esi:include src="http://localhost/date.php" />
    </p>
    

    esi 包含开始按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-16
      • 2013-02-05
      • 2018-12-23
      • 1970-01-01
      相关资源
      最近更新 更多