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

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

问题描述

当我从 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天全站免登陆