squid 不能缓存cache-control在65秒以下的页面,详见ayou同学的这篇文章:http://sudone.com/linux/squid_cache_65s.html
根据文章所说,如果想实现65秒以下的缓存呢,用last-modified头吧。
今天遇到了一个比较郁闷的事,就是架设在squid后的一台nginx,随意访问一个静态页面,死活不出last-modified头。也没作什么特殊的配置,我自己新装一个nginx,测试之。
$curl -I 127.0.0.1 HTTP/1.1 200 OK Server: nginx/0.8.32 Date: Thu, 28 Jan 2010 14:57:11 GMT Content-Type: text/html Content-Length: 151 Last-Modified: Thu, 28 Jan 2010 03:07:20 GMT Connection: keep-alive Accept-Ranges: bytes
很正常嘛,不作任何配置时默认是会有last-modified的。
后来还是经ayou同学的提醒,因为使用了ssi。。。
使用了ssi,nginx 就假设你这个页面动态的,谁知道你include的页面上次修改时间啊,当然也就不给你返回last-modified头了。
另外,使用nginx的 http_sub_module时,也不会出这个头的。在测试机上试试,加了个ssi on
$curl -I http://127.0.0.1 HTTP/1.1 200 OK Server: nginx/0.8.32 Date: Thu, 28 Jan 2010 14:57:32 GMT Content-Type: text/html Connection: keep-alive
果然是ssi。。。
mark 一下,以前就试过了,今天竟然忘了!!
补充一个,只针对shtml设置ssi就不影响的方法:
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
额,上面的方法不行。