apache环境,在http.conf中新增:

<IfModule mod_expires.c>
ExpiresActive On
<FilesMatch "\.(gif|jpg|png|js|css)$">
ExpiresDefault "access plus 7 days"
</FilesMatch>
</IfModule>

  

或:

ExpiresActive On
ExpiresByType image/gif "access plus 7 day"
ExpiresByType image/jpg "access plus 7 day"
ExpiresByType image/jpeg "access plus 7 day"
ExpiresByType image/x-icon "access plus 7 day"
ExpiresByType image/bmp "access plus 7 day"
ExpiresByType image/png "access plus 7 day"
ExpiresByType text/html "access plus 7 day"
ExpiresByType text/css "access plus 7 day"
ExpiresByType text/txt "access plus 7 day"
ExpiresByType text/js "access plus 7 day"
ExpiresByType application/x-javascript "access plus 7 day"
ExpiresByType application/x-shockwave-flash "access plus 7 day"

保存后重启web服务即可。

 

Posted on 2013-04-25 18:00  向民  阅读(244)  评论(0编辑  收藏  举报