[root@node0 varnish]# vim test.vcl # 添加如下代码
sub vcl_recv { # 定义请求的文件中如果匹配test.html就pass,就不查缓存
if (req.url ~ "test.html"){
return(pass);
}
return(lookup);
}
# 再到varnish的命令行中重新加载配置文件并应用
varnish> vcl.load test4 /etc/varnish/test.vcl
200 13
VCL compiled.
vcl.use test4
200 0
# 在命令行请求看一下缓存,不管怎么请求X-Cache都是MISS
[root@node0 varnish]# curl -I http://172.16.27.88/test.html
HTTP/1.1 200 OK
Server: Apache/2.2.15 (CentOS)
Last-Modified: Sat, 17 May 2014 09:51:07 GMT
ETag: "120905-1a-4f99578180449"
Accept-Ranges: bytes
Content-Length: 26
Content-Type: text/html; charset=UTF-8
Date: Sat, 17 May 2014 10:01:27 GMT
X-Varnish: 1309371381
Age: 0
Via: 1.1 varnish
Connection: keep-alive
X-Cache: MISS
|