注销时清除浏览器缓存 [英] Clear Brower Cache when logout

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

问题描述

我有一个包含注销"按钮的页面,当用户单击注销"时,我执行Session.Abandon()并重定向到Login.aspx.这将清除我所有的会话变量.

但是,如果我再单击浏览器中的后退"按钮,则会再次显示单击注销"之前的最后一页.我相信这是由于缓存.当我在加载页面时包括以下代码时,将不会发生此问题.

I have a page that includes a ''Logout'' button, when the user clicks ''Logout'', I perform the Session.Abandon() and redirect to Login.aspx. This clears all my session variables fine.

But, if I then click the back button in the browser, the last page before clicking ''Logout'' is rendered again. I believe this is due to caching. As when I includes the following code when loading the page, this problem will not occur.

Response.AddHeader("Cache-control", "no-store, must-revalidate, private,no-cache");
Response.AddHeader("Pragma", "no-cache");
Response.AddHeader("Expires", "0");


但是,这段代码将禁用我页面的缓存.
我不想为我的页面禁用缓存,因为它会大大降低性能.我只想找到一种仅在用户单击注销"菜单项时清除缓存的方法.
有人可以帮忙吗?


However, this piece of code will disable the cache for my page.
I do not want to disable cache for my pages because it slows down the performance considerably. I just want to find a way to clear the cache ONLY when the user clicks the ''Logout'' menu item.
Can anyone help with this?

推荐答案

从Code Project中查看此提示
注销后浏览器后退按钮问题 [
Check out this Tips from Code Project
Browser back button issue after logout[^]


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

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