cacheViews:true直到注销? [英] cacheViews:true until logout?
问题描述
我喜欢在应用程序中使用cacheViews:true ...
I like using cacheViews:true in my application...
我制作了一个具有注销/登录功能的SPA应用程序。我让某些视图根据当前用户是否是使用'viewUrl'的管理员来呈现不同的视图( HotTowel Durandal根据用户注入不同的视图)
I've made a SPA app with logout/login. Some views I have them render different views based on whether or not the current user is an administrator using the 'viewUrl' (HotTowel Durandal Inject different views based on the user)
我遇到的问题是,如果您注销管理员帐户并登录到普通用户帐户后,所有先前的视图都将被缓存,以便在浏览时弹出所有管理视图(不同的ViewModel激活功能未运行)
The problem I'm having is that if you logout of an administrator account and into a normal user account all the previous views are cached so as you navigate around it brings up all the admin views (the different viewmodels activate functions aren't running)
我正在寻找一种简单的方法,当您按下注销按钮时重置所有这些视图/视图模型,以便在下一个用户登录时该应用程序重新启动。
I'm looking for an easy way to reset all these views/viewmodels when you press the logout button so the app 'starts fresh' when the next user logs in.
推荐答案
这是一个单页应用程序,因此在注销时使用 window.location.reload()
重新加载它应用程序重新开始。
It's a single page application, so reloading it on logout by using window.location.reload()
will make the app 'start fresh'.
请确保确保配置内存消耗 cacheViews:true
时,显示该应用的版本。只要缓存的视图保留在DOM中,垃圾回收将无法重新分配内存。
With that said make sure to profile memory consumption of the app, when cacheViews: true
. As long as the cached views stay in the DOM, garbage collection won't be able to reallocate memory.
这篇关于cacheViews:true直到注销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!