![](/img/trans.png)
[英]Configuring PHP for MySQL after installing Apache & PHP from source in Ubuntu
[英]After configuring Varnish how to cache the Web Page for 2 Minutes. (Ubuntu 14.04,Apache,PHP)
我运行了以下命令,并将源代码放入/ var / www / html目录。
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
sudo apt-get install php5-curl
sudo apt-get install apache2
sudo service apache2 restart
我已按照以下链接配置Varnish以缓存网页。 但我怎么知道它的缓存与否。 我每次打开网页时都会显示相同的网页。 如何为它设置到期日。
我需要将网页缓存2分钟然后过期,那么我在哪里设置这些持续时间。
这就是我说的话
curl -I http:// localhost
HTTP/1.1 200 OK
Server: Apache/2.4.18 (Ubuntu)
ETag: "dd6d718cc03aac91085163fd1927f07a-gzip"
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Date: Wed, 03 Feb 2016 13:17:48 GMT
X-Varnish: 1965452251 1965452250
Age: 13
Via: 1.1 varnish
Connection: keep-alive
您可以通过查看请求返回的HTTP头来判断varnish是否正在缓存页面。 清漆请求将附加Age: <seconds>
作为标题,以告诉您请求的年龄。
Via: 1.1 varnish-plus-v3
Via: 1.1 varnish-plus-v3
Age: 170
您可以通过在vcl_backend_response(或vcl_fetch iirc,取决于您的清漆版本) 中的配置文件中设置beresp.ttl
值来告诉varnish缓存响应多长时间(如果没有在响应本身上设置正确的缓存头):
set beresp.ttl = 120s;
你可以通过这样做来测试
watch HEAD http://localhost:6081
这将重复HEAD请求,默认情况下每两秒显示一次URL中的标头。 您将看到Age:增加直到超过120秒,此时资源将最后一次返回并从缓存中过期(这意味着您可以看到Age: 122
即使它设置为120s)。
使用短于120秒的值对其进行测试,以确保其过期更快。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.