在 zend auth 中使用注销脚本时出现站点缓存问题
true(即身份被清除),我只需通过location.reload()重新加载浏览器
,通常会发生的是页面有以下内容:
if ($this->auth->hasIdentity()) {
echo "Welcome";
}
但是
if (!$this->auth->hasIdentity()) {
echo "some login form";
}
所以我通过ajax调用zend auth清除身份函数,如果ajax返回 然后由于该页面被浏览器缓存......即使我通过ajax调用了注销脚本(清除身份)并重新加载页面,该页面仍然显示欢迎屏幕,因为它认为该页面没有' t 改变了,所以在重新加载时只显示包含欢迎屏幕而不是登录表单的缓存......
是否可以手动清除缓存或使用 jquery 进行某种排序,这样它就不会只加载重新加载时缓存?
so I call the zend auth clear identity function through ajax and if the ajax returns true (ie the identity got cleared), i just reload the browser through location.reload()
and what usually happens is that the page has the following:
if ($this->auth->hasIdentity()) {
echo "Welcome";
}
and
if (!$this->auth->hasIdentity()) {
echo "some login form";
}
but then since the page is cached by the browser....even though I've called the logout script through ajax (which clears the identity) and reload the page, the page still displays the welcome screen since it thinks that the page hasn't changed and so just displays the cache which contains the welcome screen rather than the login form when it's reloaded......
is there away to clear the cache manually or some sort using jquery so that it won't just load up the cache when reloaded?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能是错的,但这不是更多的缓存问题吗?告诉浏览器不要缓存该特定页面,问题就应该得到解决。
I may be wrong, but wouldn't that be more of a caching issue in general? Tell the browser not to cache that specific page and the problem should be solved.
我的建议是不要使用 Ajax 实现注销功能。只需将其设置为常规链接,例如:/authentication/logout/
该操作应该执行以下操作:
无论如何,这对我有用。
我知道这可能不是一个理想的答案,但我仍然会质疑注销链接是否需要 ajax。
My recommendation is to not make your logout functionality Ajax. Just make it a regular link like: /authentication/logout/
That action should do this:
That works for me, anyway.
I understand this may not be an ideal answer, but I would still challenge the need for the logout link to be ajax.