Apache配置mod_expires或mod_headers支持CACHE

NOCO发布于 分类 Apache

更新于 2015-10-16

2天前 有1个用户阅读过

mod_expires配置

<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>

mod_headers配置

<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>

mod_expires 和 mod_headers 只需要其中一种就可以了。

-- The End --

本文标题: Apache配置mod_expires或mod_headers支持CACHE

本文地址: https://seonoco.com/blog/apache-mod-expires-or-mod-headers-cache

本文是否有所帮助?
点赞 0
感谢支持
0
多谢反馈
评论 0
打赏

支持微信/支付宝

评论

网友