我想知道您是否可以帮助我,我正在尝试为我网站中的某些文件的缓存设置过期日期,您是否可以给我一些如何做到这一点的提示?我已经能够找到一些关于如何更改整个文件类型的东西,但不是特定文件。这可能吗?
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
最佳答案
这可以帮助您: 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>
关于http - 控制缓存中文件的过期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2114414/