我有这样的configuration: – nginx端口80 – 清漆(3.0.4)端口6081 – apache端口8080
Nginx将请求传递给Varnish,然后检查caching,然后从caching中返回响应或将请求传递给Apache。 在Apache中,我禁用了mod_deflate,所以输出没有被压缩。 里面的清漆我已经启用了ESI这样的所有请求:
sub vcl_fetch { set beresp.do_esi = true; }
我的testing文件(test.php)如下所示:
Current time is: <esi:include src="/date.php" />
date.php:
<?php echo date('H:i:s');
但清漆是加工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没有被处理。
我究竟做错了什么?
解决了它…如果服务器响应的第一个字符不是“<”ESI将无法正常工作..我的问题的解决scheme只是将testing文件包装在标准的HTML结构,所以它看起来像这样:
<html> <head> <title></title> </head> <body> Current time is: <esi:include src="/name.php" /> </body> </html>
其他的方法是用参数运行Varnish守护进程:
-p esi_syntax 0x3
意思是
0x00000001 - Don't check if it looks like XML 0x00000002 - Ignore non-esi elements