htaccess:实体标签不适用于 ico 文件
一段时间以来,我一直在使用以下代码来将远期到期日期应用于静态文件并启用 gzip 压缩,但我最近注意到它似乎不适用于 .ico 文件。许多研究还没有给出答案——任何帮助/想法/线索都值得赞赏。
#####################################################
# CONFIGURE media caching
#
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header set Expires "Thu, 15 Apr 2020 20:00:00 GMT"
Header unset ETag
FileETag None
</FilesMatch>
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|php|html)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
#
#####################################################
I've been using the following code for some time to apply far future expiration dates to static files and enable gzip compression, however I've recently noticed that it does not seem to work well with .ico files. Much research has not yielded an answer - any help/thoughts/clues appreciated.
#####################################################
# CONFIGURE media caching
#
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header set Expires "Thu, 15 Apr 2020 20:00:00 GMT"
Header unset ETag
FileETag None
</FilesMatch>
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|php|html)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
#
#####################################################
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜测 mod_expires 和标头的显式设置之间存在冲突,因为它们提供了两种不同的方法来设置到期标头。
不幸的是,没有看到问题(或更多配置)中实际标头的一些示例,实际上没有足够的线索。过期标头是否以错误的日期发送,或者根本没有发送?如果日期“错误”,则到期标头可能会被 mod_expiry 替换
请注意 RFC2616 第 14.21 节 规定到期日不应超过未来一年。
I'm going to guess at a conflict between mod_expires and explicit setting of the header, as these give two different ways to set an expiry header.
Unfortunately without seeing some examples of actual headers in the question (or more of the configuration) there aren't really enough clues. Are expiry headers being sent with the wrong date, or not being sent at all? If the date is "wrong", the expiry header could be getting replaced by mod_expiry
Note that RFC2616 Section 14.21 states that an expiry date should not be more than one year in the future.
也许 .ICO 文件大小太小,发送回 304 不会给服务器负载带来任何好处。
Maybe .ICO files size is so little, that sending back a 304 would not bring any benefits in terms of server load.