IE 表现异常

发布于 2024-08-09 17:56:32 字数 569 浏览 2 评论 0原文

我们根据用户在下拉列表中选择的值通过 JavaScript 设置 Window.Location。我们设置位置的 url 没有显式设置 HTTP 缓存。

然而,我们观察到,在某些情况下,过期标头会被设置为未来 1 秒。每当发生这种情况时,更改 window.location 将停止对后续请求起作用(即使等待超过一秒),因为 IE 会缓存响应。

响应标题:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Date: Wed, 04 Nov 2009 10:51:22 GMT
Expires: Wed, 04 Nov 2009 10:51:23 GMT
ETag: 0
Vary: Accept-Encoding
Server: Microsoft-IIS/7.0
X-AspNetMvc-Version: 1.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Content-Length: 23405

我们所做的事情有问题吗?

亲切的问候,

We are setting Window.Location through JavaScript depending on the value selected by the user in a dropdown. The url we are setting the location to does not have HTTP Caching set up explicitly.

However, we have observed that in certain cases, the expires header is set in the future by 1 second. Whenever this happens, changing window.location stops working for subsequent requests (even after waiting out for more than a second) as IE caches the response.

The Response Headers:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Date: Wed, 04 Nov 2009 10:51:22 GMT
Expires: Wed, 04 Nov 2009 10:51:23 GMT
ETag: 0
Vary: Accept-Encoding
Server: Microsoft-IIS/7.0
X-AspNetMvc-Version: 1.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Content-Length: 23405

Is there something wrong with what we are doing?

Kind regards,

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

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

发布评论

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

评论(1

赴月观长安 2024-08-16 17:56:32

将随机参数附加到 url 中。

因此,

window.location.href = 'somewhere.html';

您可以使用“

window.location.href = 'somewhere.html?nocache=' + Math.random();

由于该“不同”页面尚未在缓存中”,浏览器将被迫重新加载它。

Append a random parameter to the url.

So, instead of

window.location.href = 'somewhere.html';

you could use

window.location.href = 'somewhere.html?nocache=' + Math.random();

Since that "different" page is not in the cache yet, the browser will be forced to load it fresh.

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