2011-08-13 142 views
1

我windows下配置了Apache启用缓存这样阿帕奇缓存js文件

LoadModule expires_module modules/mod_expires.so 
    LoadModule headers_module modules/mod_headers.so 
    LoadModule deflate_module modules/mod_deflate.so 

ExpiresActive On 



ExpiresDefault "access plus 3 days" 

ExpiresByType image/x-icon "access plus 1 month" 
ExpiresByType image/png "access plus 1 month" 
ExpiresByType image/jpg "access plus 1 month" 
ExpiresByType image/gif "access plus 1 month" 
ExpiresByType image/jpeg "access plus 1 month" 
ExpiresByType application/pdf "access plus 1 month" 


<IfModule mod_headers.c> 
# YEAR 
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$"> 
    Header set Cache-Control "max-age=29030400" 
</FilesMatch> 
# WEEK 
<FilesMatch "\.(js|css|swf)$"> 
    Header set Cache-Control "max-age=604800" 
</FilesMatch> 
# 45 MIN 
<FilesMatch "\.(html|htm|txt)$"> 
    Header set Cache-Control "max-age=2700" 
</FilesMatch> 
</IfModule> 

当我尝试打开JS直接在浏览器(测试)文件,每次我得到一次又一次地刷新,然后响应状态200与Firebug。它没有发送状态“304未修改”。你有什么想法我怎么能做到这一点。以下是Firebug标题的输出。

Response Header 
Date  Sat, 13 Aug 2011 01:18:15 GMT 
Server  Apache/2.2.19 (Win32) PHP/5.3.6 
Last-Modified Sat, 13 Aug 2011 01:18:15 GMT 
Etag  W/"100000000171d-34f08-4aa5f022d9780" 
Accept-Ranges bytes 
Content-Length 216840 
Cache-Control max-age=604800 
Expires  Tue, 16 Aug 2011 01:18:15 GMT 
Keep-Alive  timeout=5, max=100 
Connection  Keep-Alive 
Content-Type application/javascript 

Request Header 

Accept   text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language en-us,en;q=0.5 
Accept-Encoding gzip, deflate 
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection   keep-alive 
Cookie   PHPSESSID=5k947khv1j27itd7mtp5evtg07 
If-Modified-Since Sat, 13 Aug 2011 01:03:42 GMT 
If-None-Match W/"100000000171d-34f08-4aa5f022d9780" 
Cache-Control max-age=0 

回答