开发者

ExpiresHeader .htaccess

I am currently trying to improve website loading times and I am using the following:

<IfModule mod_expires.c>    
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/开发者_Python百科rules.html#expires
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    Header set Expires "Thu, 15 Apr 2020 20:00:00 GMT"
</FilesMatch>
</IfModule>

That works great ... I was wondering if it is possible not to have a fixed date there. Can I do something like this?

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    ExpiresDefault "access plus 10 years"
</FilesMatch>
</IfModule>

Doesn't seem to work ATM :S

Thanks

Regards Gabriel


To enable ExpiresDefault, you need to set ExpiresActive to on as in:

<IfModule mod_expires.c>
ExpiresActive On
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    ExpiresDefault "access plus 10 years"
</FilesMatch>
</IfModule>

The above answer should solve your question. For other cases: mod_expires is not a default Apache module, it's an extension. Make sure that it is enabled, which you can do using phpinfo() on a PHP-enabled server. If you have shell access, you can run apachectl -t -D DUMP_MODULES.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜