目录

htaccess 缓存设置

目录
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# 使用插件,分别设置缓存级别,没有该插件的情况下同级目录下的资源将无法访问
LoadModule expires_module modules/mod_expires.so
<IfModule expires_module>
ExpiresActive On
ExpiresDefault A3600
# 1 年
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A9030400
</FilesMatch>
# 1 星期
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
ExpiresDefault A604800
</FilesMatch>
# 3 小时
<FilesMatch "\.(txt|xml|js|css)$">
ExpiresDefault M10800
</FilesMatch>
</IfModule>

# 不使用插件,通过Header设置缓存一个月
Header set Cache-Control "max-age=2592000"