2010-01-22 92 views
2

我想知道你是否可以帮助我,我试图设置在我的网站缓存某些文件的到期日期,有没有一些提示,你可以给我如何做到这一点?我已经能够找到一些关于如何改变整个文件类型的东西,但没有找到具体的文件。那可能吗?控制缓存中文件的到期

ExpiresActive On     # enable expirations 
ExpiresByType image/gif A2592000 # expire GIF images after a month 
           # in the client's cache 
ExpiresByType text/html M604800 # HTML documents are good for a 
           # week from the time they were 
           # changed, period 

回答

2

这可以帮助你: http://viralpatel.net/blogs/2009/06/21-very-useful-htaccess-tips-tricks.html

退房提示#6: “实现与一的.htaccess缓存策略”。 我想你可以从这里想出一个基于特定文件的处理方式。

 
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$"> 
Header set Cache-Control "public" 
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" 
Header unset Last-Modified 
</FilesMatch>

<FilesMatch ".(html|htm|xml|txt|xsl)$"> Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch>

<FilesMatch ".(js|css)$"> Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" </FilesMatch>