apache响应报文头部设置

来源:互联网 发布:应用程序劫持软件 编辑:程序博客网 时间:2024/06/05 23:46

转载:http://www.turbocms.com/support/kb/6801.shtml

Apache里配置 mod_expires 和 mod_headers 以支持CACHE


<IfModule mod_expires.c>
 ExpiresActive On
 ExpiresDefault "access plus 1 days"
 ExpiresByType text/html "access plus 1 weeks"
 ExpiresByType image/gif "access plus 2 months"
 ExpiresByType image/jpeg "access plus 2 months"
 ExpiresByType application/x-shockwave-flash "access plus 2 months"
 ExpiresByType application/x-javascript "access plus 2 months"
</IfModule>

<IfModule mod_headers.c>
# YEAR
<FilesMatch "\.(flv|gif|ico|jpeg)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

# WEEK
<FilesMatch "\.(pdf|swf|js|css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>

# DAY
<FilesMatch "\.(htm|html|shtml)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
</IfModule>