嗨,我有以下问题。我有一个运行laravel 5.1的网站,为了让网站对许多用户可用,并有更快的加载时间,我使用了Varnish4。我的清漆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);
}
正如您所看到的,我为所有请求启用esiprocessign(不是最佳实践,但我正在努力使其正常工作),并删除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块,因为没有显示回退(显示NO ESI SUPPORT)消息。
那么,这个代码会出什么问题呢?
已解决。
出于某种原因:
<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的加入开始如预期的那样发挥作用。
esi:include标签只采用路径,而不是带有协议和主机名等的完整URL,例如
<esi:include src="/cgi-bin/date.cgi"/>
请参阅:https://www.varnish-cache.org/docs/4.1/users-guide/esi.html