问题描述
我在运行Apache的共享主机上.显然未安装mod_expires.在该环境中,还有另一种方法可以将过期标题添加到css文件,图像等吗?
I'm on a shared host running Apache. Apparently mod_expires is not installed.Is there another way to add expires headers to css-files, images etc. on that environment?
推荐答案
在您的.htaccess
中(如果可以的话),您可以使用 <FilesMatch>
块与 Header
指令.不过,这需要mod_headers
,而且我很确定您不能指定滚动"到期日期(即从现在开始一年").因此,您需要编辑此设置,例如,每年一次.
In your .htaccess
(if that's an option) you can use a <FilesMatch>
block with Header
directives. This requires mod_headers
, though, and I'm pretty sure that you can't specify a "rolling" expiration date (i.e., "one year from now"). Therefore, you'll need to edit this setting, say, once a year.
另外,您是否看到此问题?
显然,您应该避免将Expires
设置为超过一年的时间:请勿将其[Expires
标头]设置为多个违反了RFC准则."(来源:优化缓存)
Apparently you should refrain from setting the Expires
to more than a year into the future: "Do not set it [the Expires
header] to more than one year in the future, as that violates the RFC guidelines." (source: Optimize caching)
这篇关于Apache:如何在未安装mod_expires的文件中添加Expires标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!