如果我这样做:
<IfModule mod_expires.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|css|js|php)$">
ExpiresActive On
ExpiresDefault "access plus 30 days"
</FilesMatch>
</IfModule>
它没有正确设置 Expire header ,而如果我像这样手动“强制”它:
<IfModule mod_expires.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|css|js|php)$">
ExpiresActive On
Header set Expires "Thu, 18 Jan 2012 20:00:00 GMT"
</FilesMatch>
</IfModule>
有用。这意味着两件事:
IfModule mod_expires.c
为真)我错过了什么?
顺便说一句:如果您有任何解决方案可以使其发挥作用,我就是您的男人!
最佳答案
好的,我从官方文档 here 中得到了它:
Note that if you use a modification date based setting, the Expires header will not be added to content that does not come from a file on disk. This is due to the fact that there is no modification time for such content.
所以它只适用于静态文件,而不适用于所有其他文件:它们不是静态的。
关于Apache:ExpiresDefault 不起作用,而 "Header"起作用。怎么会?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8822559/