这两天在看squid反向代理加速web应用方面的内容。

总体来看squid的cache都是缓存一些静态内容,例如图片、css、js等文件。而动态内容是不能缓存的。那有没有办法让squid缓存php文件呢?答案是肯定的。

首先用squid反向代理后,我们访问一个test.html的静态页面。

[root@localhost ~]# curl -I http://xinlogs.com:3128/test.html

HTTP/1.0 200 OK

Content-Type: text/html

Content-Length: 77

Accept-Ranges: bytes

Server: Tengine/1.2.1

Date: Tue, 17 Jan 2012 12:38:36 GMT

Last-Modified: Tue, 17 Jan 2012 01:29:47 GMT

X-Cache: HIT from squid.xinlogs.com

Via: 1.1 squid.xinlogs.com:3128 (squid/2.7.STABLE9)

Connection: close

可以看到X-Cache: HIT from squid.xinlogs.com,成功命中缓存。说明是被squid缓存的内容直接给我们了。

而访问一个动态页面呢?

阅读全文>>