首页 \ 问答 \ 用mod_expires覆盖缓存头(Overwrite cache-headers with mod_expires)

用mod_expires覆盖缓存头(Overwrite cache-headers with mod_expires)

我想使用apache的mod_expires模块设置缓存头。 我的配置看起来有点像这样:

<LocationMatch ^/static >
    ExpiresDefault "access plus 1 years"
</LocationMatch>

问题是,这些文件是由我不控制的第三个系统生成的。 这些系统为文件提供以下标题:

Date Mon, 24 Oct 2011 08:39:02 GMT
Cache-Control no-cache,no-store,must-revalidate
Pragma no-cache
Expires Thu, 01 Dec 1994 16:00:00 GMT

这些标头使得不可能使用mod_expires设置缓存标头。 http://httpd.apache.org/docs/2.2/mod/mod_expires.html告诉我们为什么:

当Expires头已经是服务器产生的响应的一部分时,例如当由CGI脚本产生或从源服务器代理时,这个模块不会改变或添加Expires或Cache-Control头。

有没有什么可能的方法来绕过这个规则,并用mod_expires覆盖头文件?

更新:一种可能的解决方案,为了避免这种限制,只能使用mod_headers来设置缓存头。 不幸的是,这不是一种替代方案,因为必须计算这些值。

感谢它的进步。


I want to set cache-headers using the mod_expires module from apache. My configuration looks somewhat like this:

<LocationMatch ^/static >
    ExpiresDefault "access plus 1 years"
</LocationMatch>

The problem is, that the files are generated by a third system I don't control. These system provides files with the following headers:

Date Mon, 24 Oct 2011 08:39:02 GMT
Cache-Control no-cache,no-store,must-revalidate
Pragma no-cache
Expires Thu, 01 Dec 1994 16:00:00 GMT

These headers makes it impossible to set the cache-headers with mod_expires. http://httpd.apache.org/docs/2.2/mod/mod_expires.html tells us why:

When the Expires header is already part of the response generated by the server, for example when generated by a CGI script or proxied from an origin server, this module does not change or add an Expires or Cache-Control header.

Is there any possible way to circumvent this rule and overwrite the headers with mod_expires?

Update: One possible solution, to avoid this limitation is to use only mod_headers to set the cache-headers. Unfortunately, this isn't an alternative because the values have to be calculated.

Thanks it advance.


原文:https://stackoverflow.com/questions/7930140
更新时间:2023-11-11 16:11

最满意答案

在进一步调查中,我发现自己用jQuery datepicker搞砸了它。

Bootstrap datepicker ,没有类似onClose()方法,但使用changeDate可以简单地解决问题。

$('#start').datepicker({
    autoclose: true  // This enable you to close the picker
}).on('changeDate', function (ev) {
    $("#end").focus();
});
$('#end').datepicker();

仅供参考:要关闭选择器,可以在bootstrap datepicker中使用autoclose属性。

这是一个简单的JSFiddle给你。


On further investigation, I found myself that I messed it with jQuery datepicker.

Here in Bootstrap datepicker, there is no method like onClose() but using changeDate you can simply accomplish the issue.

$('#start').datepicker({
    autoclose: true  // This enable you to close the picker
}).on('changeDate', function (ev) {
    $("#end").focus();
});
$('#end').datepicker();

FYI: To close your picker, you make use of autoclose property in bootstrap datepicker.

Here is a simple JSFiddle for you.

相关问答

更多
  • 在进一步调查中,我发现自己用jQuery datepicker搞砸了它。 在Bootstrap datepicker ,没有类似onClose()方法,但使用changeDate可以简单地解决问题。 $('#start').datepicker({ autoclose: true // This enable you to close the picker }).on('changeDate', function (ev) { $("#end").focus(); }); $('#end' ...
  • 我们不支持选择器中的两个日期,但您可以使用两个选择器来表示开始时间,一个用于表示结束时间。 We don't support two dates in the picker, but you can use two pickers one to represent the start time and one to represent the end time.
  • 给你的输入命名,发帖后,转储$_POST['yourName'] ,看看你得到了什么。 Give a name to your input and after post, dump $_POST['yourName'] and see what you get.
  • 我运行了你的代码和配置,并看到了你所看到的相同行为。 在将您的配置与我工作的配置进行比较之后,我意识到问题是在您的AndroidManifest.xml中,您需要更改此设置: android:name="com.google.android.maps.v2.API_KEY" 对此: android:name="com.google.android.geo.API_KEY" 我回去并使用这两种配置进行了多次测试,以确保这是造成问题的原因。 使用第一个配置,PlacePicker每次都会立即关闭。 使用co ...
  • 我刚刚在你的代码中添加了以下代码,在这里我们点击按钮调用'getDate()' ,试试这段代码