sub vcl_fetch {
if (req.url ~ "html$") {
set beresp.ttl = 10m;
set beresp.do_gzip = true;
unset beresp.http.Cache-Control;
unset beresp.http.Pragma;
set beresp.http.Cache-Control = "max-age=600";
unset beresp.http.Expires;
}
}
备注:如果rewrite后的html页面带cookie,还得在sub vcl_recv { } 配置里添加如下内容
sub vcl_recv {
if (req.request == "GET" && req.url ~ "\.(js|css|html|jpg|png|gif|swf|jpeg|ico|mp3)$") {
unset req.http.cookie;
}
}
以上配置文件,合适版本 varnish 3.0.x
qingheliu 2013-08-27
fenghao.cn 2011-10-10