Javascript 在Angular js中从浏览器缓存中删除会话
我使用AngularJS作为前端,Java作为后端。我需要在用户关闭选项卡时使会话无效,而不考虑会话。每当他点击url时,他需要被重定向到登录页面 我已尝试在index.html中包含以下内容Javascript 在Angular js中从浏览器缓存中删除会话,javascript,angularjs,session,browser-cache,Javascript,Angularjs,Session,Browser Cache,我使用AngularJS作为前端,Java作为后端。我需要在用户关闭选项卡时使会话无效,而不考虑会话。每当他点击url时,他需要被重定向到登录页面 我已尝试在index.html中包含以下内容 <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="cache-control" content="max-age=0" /
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="cache-control" content="no-store" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="-1" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
有谁能建议我做什么
也需要在IE中处理这个问题
提前感谢您好,请在调用的第一个控制器中清除会话。稍后在statechange中添加一个条件,即如果会话为空,则转到登录页面<代码>$window.sessionStorage.clear()$window.localStorage.clear()代码>如果有许多选项卡打开,那么一旦其中一个选项卡关闭,会话是否应该无效?这足够了吗?Alexis Toby,它不工作。Jin,一次只打开一个选项卡。如果该选项卡关闭,则必须使会话无效。
app.run(function($templateCache) {
$(window).on('beforeunload', function() {
$templateCache.removeAll();
});
});
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
});