如何阻止chrome缓存

发布于 2024-10-01 18:36:00 字数 248 浏览 1 评论 0原文

当用户按下后退按钮时,我需要强制浏览器从服务器重新加载上一页。

我已将以下内容添加到我的响应标头中:

Cache-Control: no-cache, must-revalidate
Expires: -1

这似乎适用于大多数浏览器,但不适用于坚持返回缓存结果的 Google Chrome。

那么有谁知道当用户按下后退按钮时如何强制浏览器从服务器获取页面?

谢谢。

I need to force the browser to reload the previous page from the server when the user presses the back button.

I've added the following to my response headers:

Cache-Control: no-cache, must-revalidate
Expires: -1

This seems to work for most browsers but not for Google Chrome that insists on returning the cached results.

So does anyone know how I force the browser to get the page from the server when the user presses the back button?

Thank you.

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

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

发布评论

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

评论(2

似最初 2024-10-08 18:36:00

根据 chromium 存储库中的此错误报告,用户发现使用no-store 而不是 no-cache 将在 chrome 中修复它。

as per this bug report in chromium repo, users find that using no-store instead of no-cache will fix it in chrome.

め可乐爱微笑 2024-10-08 18:36:00

这是不正确的,但也许您可以使用 Javascript 历史对象来确定当前页面是否是列表中的最后一页?如果没有,则按下后退按钮。

请参阅此参考:http://www.exforsys .com/tutorials/javascript/javascript-history-object-properties-and-methods.html

当然,真正的解决方案是以后退/前进按钮的使用方式实际工作的方式构建您的应用程序应该是。

This is not proper, but perhaps you could use the Javascript history object to determine if the current page is the last page in the list? If not, the back button was pressed.

See this reference: http://www.exforsys.com/tutorials/javascript/javascript-history-object-properties-and-methods.html

The real solution of course is to structure your application in such a way that usage of back/forward buttons actually work the way they are supposed to.

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