IE 302 重定向无缓存标头问题

发布于 2024-07-10 17:55:11 字数 314 浏览 4 评论 0原文

发布信息后返回 302 重定向。 此重定向旨在重新加载当前页面。

这一切都工作正常,但 IE 在标头中添加了 No-Cache:

Cache-Control: no-cache

我们使用 Squid 来缓存我们的内容,并将其放在标头中会绕过鱿鱼。
由于此重定向经常使用(没有办法解决这个问题),这会大大增加我们系统的负载。

Firefox 没有这个问题,它只是请求重定向的页面而不更改标头,即正是我们想要的。

我们可以做些什么来阻止 IE 添加无缓存吗?

A 302 Redirect is being returned after a post of information. This redirect is intended to reload the current page.

This all works fine, but IE adds No-Cache to the header:

Cache-Control: no-cache

We are using Squid to cache our content, and putting this in the header bypasses squid.
As this redirect is used quite often(there is no way around this), this increases load on our system substantially.

Firefox doesn't have this problem, it simply requests the redirected page without changing the header which is exactly what we want.

Is there anything we can do to stop IE from adding no-cache?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

楠木可依 2024-07-17 17:55:11

迷人。 这确实是一个 IE 问题,没有直接的解决方法。 问题在于,IE 会无条件地向 HTTP POST 请求添加 Cache-Control: no-cache 请求标头(如果有代理,则添加 Pragma: no-cache 请求标头)。

毫无疑问,这是十多年前在 IE 中引入的,目的是为了适应有缺陷的代理服务器,这些代理服务器无法正确处理 HTTP POST 请求,并且会错误地返回缓存的响应。

IE 的一个怪癖是,当您重定向时,无缓存标头会重新添加到重定向的请求中。 因此,在您的情况下,您的重定向请求还会发送从 POST 请求中继承的“no-cache”请求标头。

不幸的是,没有直接的解决方法。 您可以将 IE 用户重定向到插页式页面,该页面使用 JavaScript 将他们重定向回原始页面。 (但是不要使用 META REFRESH,因为它总是发送无缓存请求)。

Fascinating. This is indeed an IE issue with no direct workaround. The problem is that IE will unconditionally add a Cache-Control: no-cache request header (or a Pragma: no-cache request header if you have a proxy) to a HTTP POST request.

This was doubtless introduced in IE over a decade ago to accomodate buggy proxy servers which did not properly handle HTTP POST requests and would incorrectly return cached responses.

A quirk of IE is that when you redirect, the no-cache headers are re-added to the redirected request. Hence, in your case, your redirected request also sends the "no-cache" request header carried over from the POST request.

Unfortunately, there's no direct workaround for this. You could redirect IE users to an interstitial page that uses JavaScript to redirect them back to the original page. (Don't use META REFRESH though, because that ALWAYS sends no-cache requests).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文