Apache:如何在未安装mod_expires的文件中添加Expires标头 [英] Apache: How to add Expires headers to files without mod_expires installed

查看:81
本文介绍了Apache:如何在未安装mod_expires的文件中添加Expires标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行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中(如果可以的话),您可以使用 Header指令.不过,这需要mod_headers,而且我很确定您不能指定滚动"到期日期(即从现在开始一年").因此,您需要编辑此设置,例如,每年一次 1 .

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 year1.

另外,您是否看到此问题?

1)显然,您应该避免将Expires设置为超过一年的时间:请勿将其[Expires标头]设置为多个违反了RFC准则."(来源:

1) 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标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆