用于利用浏览器缓存的特定文件

时间:2017-01-04 05:12:10

标签: .htaccess x-cart

我在htaccess

中添加了以下代码
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ## 

但我仍然需要添加一些文件以利用浏览器缓存。

我可以在.htaccess中添加特定文件以利用浏览器缓存吗?

1 个答案:

答案 0 :(得分:2)

你不能。

http://httpd.apache.org/docs/current/mod/mod_expires.html

Apache模块mod_expires支持3个指令

  • ExpiresActive
  • ExpiresByType
  • ExpiresDefault

ExpiresByType 指令的语法是

http://httpd.apache.org/docs/current/mod/mod_expires.html#expiresbytype
ExpiresByType MIME-type <code>seconds

http://httpd.apache.org/docs/current/mod/mod_expires.html#AltSyn  
ExpiresByType type/encoding "base[plus num type] [num type] ..."