简体   繁体   English

浏览器后退按钮显示缓存中的页面?

[英]Browser back button showing the page from cache?

When I logout from wordpress website, it will be redirected to the login page. 当我从wordpress网站注销时,它将被重定向到登录页面。 But the issue is, if I hit the browser back button, It will show the previous page, which need the authorization. 但问题是,如果我点击浏览器后退按钮,它将显示上一页,需要授权。 I know, the page is being loaded from the browser cache and no interaction with the server is happening. 我知道,页面正在从浏览器缓存中加载,并且没有与服务器进行任何交互。 But I need to force the page to reload if the user hit the browser back button. 但是如果用户点击浏览器后退按钮,我需要强制页面重新加载。

I did check the header and I could find the following 我确实检查了标题,我可以找到以下内容

Cache-Control:  no-cache, must-revalidate, max-age=0

I have also tried by adding the following meta tags and it didn't work. 我也尝试添加以下元标记,但它不起作用。

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

Please help 请帮忙

I have tried by setting header like below and it worked like a charm! 我试过设置如下所示的标题,它就像一个魅力!

header("Cache-Control: private, must-revalidate,
        max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
      );

Tried lot of solutions but only the below one worked out . 尝试了很多解决方案,但只有下面的解决方案。 Added below java script in the logout page. 在注销页面中添加了以下java脚本。 All the other solutions will work fine in browsers other than IE. 所有其他解决方案在IE以外的浏览器中都能正常工作。

window.onunload = function() {
    window.location.href = "<%=request.getContextPath()%>/logout.jsp";
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM