我的配置如下:- nginx端口80 -清漆(3.0.4)端口6081 - apache端口8080
Nginx接收请求并将其传递给Varnish,后者检查缓存,然后从缓存返回响应,或者将请求传递给Apache。在Apache中,我禁用了mod_deflate,因此输出没有压缩。我为所有这样的请求启用了ESI:
sub vcl_fetch {
set beresp.do_esi = true;
}我的测试文件(test.php)如下所示:
Current time is: <esi:include src="/date.php" /> date.php:
<?php
echo date('H:i:s');但是Varnish是对esi包括的处理。在varnishlog中,我得到了以下错误:
11 ESI_xmlerror c No ESI processing, first char not '<'来自test.php的响应头:
Accept-Ranges:bytes
Age:3
Connection:keep-alive
Content-Length:51
Content-Type:text/html
Date:Sun, 01 Sep 2013 11:51:57 GMT
Server:nginx
Surrogate-Control:"ESI/1.0"
Via:1.1 varnish
X-Powered-By:PHP/5.4.15-1~precise+1
X-Varnish:1236304062 1236304061以及html输出:
Current time is: <esi:include src="/name.php" /> 所以你可以看到ESI没有被处理。
我做错了什么?
发布于 2013-09-01 13:34:20
解决了它..。如果服务器响应的第一个字符不是"<“,则ESI将无法工作。我的问题的解决方案是将测试文件包装成标准的HTML结构,这样看起来如下所示:
<html>
<head>
<title></title>
</head>
<body>
Current time is: <esi:include src="/name.php" />
</body>
</html>发布于 2013-09-01 23:08:34
另一种方法是使用参数运行Varnish守护进程:
-p esi_syntax 0x3这意味着
0x00000001 - Don't check if it looks like XML
0x00000002 - Ignore non-esi elementshttps://serverfault.com/questions/535436
复制相似问题