Varnish Cache 不会进行 ESI 包含
即使是最简单的 Varnish Cache,我也遇到问题 ESI 测试有效。
经过尝试和尝试后,我想我在这里问。
基本上它不会包含 ESI 文件。刚刚回归 HTML 而不执行包含操作。
这是我的清漆启动命令:
varnishd -f /etc/varnish/default.vcl -s malloc,128M -T 127.0.0.1:2000 -a 0.0.0.0:8080;
这是我正在测试的 URL:
http://vbox.local:8080/varnish-tests/test.php
我的 vcl 规则:
1) default.vcl
backend default {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_fetch {
if (req.url ~ "test.php") {
esi; /* Do ESI processing */
set beresp.ttl = 24h;
} elseif (req.url ~ "esi_1.php") {
set beresp.ttl = 1m;
}
return(deliver);
}
我的示例测试 esi 代码
2) test.php
<html>
<head>
<?php echo "Time 1: ".time(); ?>
<br />
The time 2 is: <esi:include src="/varnish-tests/esi_1.php"/> at this very moment.
</body>
</html>
到 esi 的 php 包含
3) esi_1.php
<?php
echo "Time 2: ".time();
?>
我已经尝试过上述 vcl 规则的许多变体。
一切都不起作用。只是看不出我哪里错了?
非常感谢任何建议/帮助。
谢谢。
I am having problems getting even the simplest of Varnish Cache
ESI tests to work.
After trying and trying I thought I ask here.
Basically it just wont include the ESI file. It's just returning
the HTML without doing it's include.
Here is my varnish start command:
varnishd -f /etc/varnish/default.vcl -s malloc,128M -T 127.0.0.1:2000 -a 0.0.0.0:8080;
Here is the URL I'm testing with:
http://vbox.local:8080/varnish-tests/test.php
My vcl rules:
1) default.vcl
backend default {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_fetch {
if (req.url ~ "test.php") {
esi; /* Do ESI processing */
set beresp.ttl = 24h;
} elseif (req.url ~ "esi_1.php") {
set beresp.ttl = 1m;
}
return(deliver);
}
My sample test esi code
2) test.php
<html>
<head>
<?php echo "Time 1: ".time(); ?>
<br />
The time 2 is: <esi:include src="/varnish-tests/esi_1.php"/> at this very moment.
</body>
</html>
The php to esi include
3) esi_1.php
<?php
echo "Time 2: ".time();
?>
I've tried many variations of the above vcl rules.
All don't work. Just can't see where I'm going wrong?
Any advise/help much appreciated.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
问题是 Varnish 和 mod_deflate 目前不能很好地协同工作。
删除 deflate.conf 和 deflate.load 解决了问题。
干杯。
The problem is Varnish and mod_deflate don't work together well at this time.
Removing deflate.conf and deflate.load fixed the problem.
Cheers.
尝试使用 Varnish 3.0 beta1 进行测试。它的主要新功能之一是完全压缩支持(这意味着它现在也可以与 ESI 一起使用):
https://www.varnish-software.com/blog/varnish-cache-30-beta-1-out
这样你就可以避免改变 apache 上的任何内容/php 压缩处理设置。
Try testing with Varnish 3.0 beta1. One of its main new features is full compression support (which means that it now works also with ESI):
https://www.varnish-software.com/blog/varnish-cache-30-beta-1-out
With that you'll probably avoid changing anything on your apache/php compression handling settings.
鉴于最新的错误,此博文可能相关。
某些版本的 Varnish 似乎不能很好地处理 gzip 压缩的内容。您是否已将 PHP 设置为执行 gzip 压缩?您是否将托管 PHP 的 Web 服务器软件设置为执行 gzip 压缩?
Varnish 也可能会阻塞格式不良的内容,尽管这在这里似乎不太可能......
不幸的是我现在没有主意了。
Given the newest error, this blog post may be relevant.
It seems that certain versions of Varnish don't handle gzipped content well. Do you have PHP set to perform gzip compression? Do you have the web server software hosting PHP set to perform gzip compression?
Varnish also can choke over poorly-formed content, though that doesn't seem to be likely here...
Unfortunately I'm now out of ideas.
对于 vcl_fetch 中的 Varnish 3.x
,我必须添加:
For Varnish 3.x
in vcl_fetch, I had to add: