[求助]apache如何才能cache静态内容??
roadli
|
1#
roadli 发表于 2006-08-25 17:42
[求助]apache如何才能cache静态内容??
环境:Freebsd4.8+apache1.3.28
编译了mod_proxy模块,并做了如下设置
[Copy to clipboard] [ - ]
CODE:
ProxyRequests On
CacheRoot /mnt/cache CacheSize 5000 CacheGcInterval 4 CacheMaxExpire 24 CacheLastModifiedFactor 0.1 CacheDefaultExpire 1 按照常规,第一次浏览,IE正常下载数据,然后按F5刷新页面,应该先检查本地缓存,如果本地有缓存,而没有过期的话,就返回304,直接显示缓存中的数据,而不会再从服务器下载一次了 但是我这得情况是,我访问一次后,按F5刷新页面,IE还是去服务器下载数据,本地没有缓存 而我访问,比如百度首页,就能会缓存,而不再从服务器下载数据了,这说明我本地的浏览器没问题。 我抓了一下访问的http头,大家看一下 第一次访问我的页面
[Copy to clipboard] [ - ]
CODE:
--- WD_CV_WS2_HTTP_HEADER_REQUEST(1057) CSTRING(7) Length=256
GET /images/test.gif HTTP/1.1 Accept: */* Referer: http://www.test.com/ Accept-Language: zh-cn Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon) Host: www.test.com Connection: Keep-Alive --- WD_CV_WS2_HTTP_HEADER_REPLY(1056) CSTRING(7) Length=368 HTTP/1.1 200 OK Date: Fri, 25 Aug 2006 08:49:05 GMT Server: Apache Vary: Accept-Encoding Cache-Control: max-age=2592000 Expires: Sun, 24 Sep 2006 08:49:05 GMT Last-Modified: Thu, 27 Apr 2006 07:46:39 GMT ETag: "27511d-693-445076df" Accept-Ranges: bytes Content-Length: 1683 Keep-Alive: timeout=60, max=100 Connection: Keep-Alive Content-Type: image/gif 然后按F5刷新页面
[Copy to clipboard] [ - ]
CODE:
--- WD_CV_WS2_HTTP_HEADER_REQUEST(1057) CSTRING(7) Length=256
GET /images/test.gif HTTP/1.1 Accept: */* Referer: http://www.test.com/ Accept-Language: zh-cn Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon) Host: www.test.com Connection: Keep-Alive --- WD_CV_WS2_HTTP_HEADER_REPLY(1056) CSTRING(7) Length=367 HTTP/1.1 200 OK Date: Fri, 25 Aug 2006 08:50:19 GMT Server: Apache Vary: Accept-Encoding Cache-Control: max-age=2592000 Expires: Sun, 24 Sep 2006 08:50:19 GMT Last-Modified: Thu, 27 Apr 2006 07:46:39 GMT ETag: "27511d-693-445076df" Accept-Ranges: bytes Content-Length: 1683 Keep-Alive: timeout=60, max=99 Connection: Keep-Alive Content-Type: image/gif 两次请求一样,没有本地缓存 我有访问了一下baidu的首页
[Copy to clipboard] [ - ]
CODE:
--- WD_CV_WS2_HTTP_HEADER_REQUEST(1057) CSTRING(7) Length=299
GET /img/logo.gif HTTP/1.1 Accept: */* Referer: http://www.baidu.com/ Accept-Language: zh-cn Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon) Host: www.baidu.com Connection: Keep-Alive Cookie: BAIDUID=28AB0CE05D8D9EB4047F791837F33E5C --- WD_CV_WS2_HTTP_HEADER_REPLY(1056) CSTRING(7) Length=297 HTTP/1.1 200 OK Date: Fri, 25 Aug 2006 08:53:08 GMT Server: Apache/1.3.27 Cache-Control: max-age=315360000 Expires: Mon, 22 Aug 2016 08:53:08 GMT Last-Modified: Mon, 12 Jun 2006 13:15:16 GMT ETag: "346e73-628-448d68e4" Accept-Ranges: bytes Content-Length: 1576 Content-Type: image/gif 第一次正常下载数据 然后我按F5刷新页面
[Copy to clipboard] [ - ]
CODE:
--- WD_CV_WS2_HTTP_HEADER_REQUEST(1057) CSTRING(7) Length=387
GET /img/logo.gif HTTP/1.1 Accept: */* Referer: http://www.baidu.com/ Accept-Language: zh-cn Accept-Encoding: gzip, deflate If-Modified-Since: Mon, 12 Jun 2006 13:15:16 GMT If-None-Match: "346e73-628-448d68e4" User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon) Host: www.baidu.com Connection: Keep-Alive Cookie: BAIDUID=28AB0CE05D8D9EB4047F791837F33E5C --- WD_CV_WS2_HTTP_HEADER_REPLY(1056) CSTRING(7) Length=192 HTTP/1.1 304 Not Modified Date: Fri, 25 Aug 2006 08:53:27 GMT Server: Apache/1.3.27 ETag: "346e73-628-448d68e4" Expires: Mon, 22 Aug 2016 08:53:27 GMT Cache-Control: max-age=315360000 baidu的就是正常的304,没有再次去下载数据 这让我非常郁闷,有谁知道这是为什么吗? 百度也是用的apache阿,它是怎么实现的呢? |