浏览器后退按钮显示来自缓存的页面? [英] Browser back button showing the page from cache?

查看:112
本文介绍了浏览器后退按钮显示来自缓存的页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从wordpress网站注销时,它将被重定向到登录页面.但是问题是,如果我按下浏览器的后退按钮,它将显示前一页,需要授权.我知道,该页面是从浏览器缓存中加载的,并且与服务器之间没有任何交互.但是如果用户点击浏览器的后退按钮,我需要强制重新加载页面.

When I logout from wordpress website, it will be redirected to the login page. 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">

请帮助

推荐答案

我尝试通过设置如下所示的标头来工作,它像一种魅力一样!

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"
      );

这篇关于浏览器后退按钮显示来自缓存的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆