2010-01-22 70 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>