172.16.0.101 - - [04/Sep/2014:16:43:27 +0800] "GET /favicon.ico HTTP/1.1" 404 288 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
4、设置查看是否命中缓存
Node1
Vim /etc/varnish/test.vcl
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "Hit Via"+" "+ server.hostname;
} else {
set resp.http.X-Cache = "Miss Via"+" "+ server.hostname;
}
return (deliver);
}
[root@localhost ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082
varnish> vcl.load test2 test1.vcl
200
VCL compiled.
varnish> vcl.use test2
200
varnish> vcl.list
200
available 0 boot
available 2 test1
active 0 test2
浏览器访问F12查看
5、精确设置那个页面不用缓存
if (req.url ~”~/test.html$”) {
Return(pass)
}
编译使用
Vcl.load test3 test1.vcl
Vcl.use test2
Vcl.list
浏览器测试
变量使用规则
6、内置变量使用的在那个状态引擎中