无法禁用 jsp 缓存

发布于 2024-11-15 20:17:08 字数 296 浏览 4 评论 0原文

我不希望浏览器缓存指定的jsp,所以我在我的jsp中使用了下面的代码:

<%
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
%>

但是,它不起作用。每次我按后退按钮时,浏览器都会显示缓存的页面而不刷新。

jsp中代码的位置重要吗?如何禁用缓存?

I don't want the browser to cache a specified jsp, so I used the code below in my jsp:

<%
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
%>

However, it doesn't work. Everytime I press the back button, the browser shows the cached page without refreshing.

Does the position of the code in the jsp matter? How to disable the cache?

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

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

发布评论

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

评论(1

蹲在坟头点根烟 2024-11-22 20:17:08

拼写错误? Pramga 而不是 Pragma?尝试。

<%        
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
    response.setDateHeader("Expires", -1);
%>

编辑:看到这个问题 How to control web page跨所有浏览器缓存?

A typo? Pramga instead of Pragma? Try.

<%        
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
    response.setDateHeader("Expires", -1);
%>

EDIT: see this question How to control web page caching, across all browsers?

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