当您在注销后点击后退按钮时,浏览器会从缓存中加载前一页。为了防止受保护的页面被缓存,您必须设置以下标题为this question
self.set_header('Cache-Control', 'no-cache, no-store, must-revalidate')
self.set_header('Pragma', 'no-cache')
self.set_header('Expires', '0')
描述你可以把在一个装饰,是这样的:
def protected(method):
@tornado.web.authenticated
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
self.set_header('Cache-Control', 'no-cache, no-store, must-revalidate')
self.set_header('Pragma', 'no-cache')
self.set_header('Expires', '0')
return method(self, *args, **kwargs)
return wrapper
然后用@装饰你的受保护的网页保护而不是@ tornado.web.authenticated。
整洁!在被@Mutant指向后,我发现了自己的缓存控制。不过,你的答案似乎比我要做的要干净得多。 – magicpanda