因此,请将我的vhost.conf文件设置为具有此Expires:
ExpiresActive On
ExpiresDefault "access plus 4 hours"
ExpiresByType application/javascript "access plus 10 years"
ExpiresByType application/x-javascript "access plus 10 years"
ExpiresByType text/javascript "access plus 10 years"
ExpiresByType text/html "access plus 1 hour"
ExpiresByType text/xml "access plus 1 hour"
ExpiresByType text/css "access plus 10 years"
ExpiresByType text/plain "access plus 1 hour"
ExpiresByType image/gif "access plus 10 years"
ExpiresByType image/jpg "access plus 10 years"
ExpiresByType image/jpeg "access plus 10 years"
ExpiresByType image/png "access plus 10 years"
ExpiresByType image/bmp "access plus 10 years"
ExpiresByType application/x-shockwave-flash "access plus 10 years"
我认为它正在工作,因为响应标头将返回一个Cache-control集回到未来:
Cache-Control max-age=315360000
Expires Sun, 04 Apr 2021 12:27:12 GMT
但我看看Firefox的Cache选项卡,看起来并不令人满意
Last Modified Thu Apr 07 2011 20:27:08 GMT+0800 (Malay Peninsula Standard Time)
Last Fetched Thu Apr 07 2011 20:27:09 GMT+0800 (Malay Peninsula Standard Time)
Expires Sun Apr 04 2021 20:27:07 GMT+0800 (Malay Peninsula Standard Time)
这是发生了什么。每次我重新加载我的网站时,Last Modified标头总是设置为我当前的时间。我没有修改文件,为什么它会返回我当前的时间?
答案 0 :(得分:3)
这是一个PHP脚本,其输出是在您运行脚本时生成的,因此输出从未存在过,这意味着服务器无法将缓存标头附加到该脚本。
您需要通过header()
电话自行设置上次修改时间。