注销后的浏览器后退按钮 [英] Browser back button after log out

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

问题描述

注销后如何防止浏览器使用页面的缓存副本?

How can i prevent browser using the cached copy of the page after log out ?

当用户仍然注销时,他们可以使用后退"按钮访问上一页.

When user logged out still they can access the previous pages by using the back button.

我了解我们无法禁用后退按钮(按照SO的回答).

I understand that we cannot disable the back button (as per SO answers).

目前,在不同的情况下我有大量的页面,因此我无法修改每个页面.

Currently i have a large number of pages in different scenarios so i cannot modify each and every page.

我尝试过的事情

  1. 设置到期标头(我是否需要在每个页面上都设置此标头?如果我这样做也浏览器会缓存页面内容吗?(因为如果用户登录,我需要浏览器来缓存内容))
  2. 我已经有一个轮询系统(但是仍然存在检测延迟)
  3. 基于Javascript的解决方案(它可以运行,但是用户仍然可以使用历史记录"选项进行导航或长按后退"按钮)

我真的被困在这里,请您帮我解决问题?

I am really stuck here , Could you please help me to solve the problem ?

推荐答案

我认为这段代码会帮助您,请在父控制器构造函数中使用此代码.

I think this code will help you, use this code in parent controller constructor.

//Log out Back
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.

这篇关于注销后的浏览器后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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