我正在尝试在python webpy框架中构建网站,但在Web浏览器的缓存控制方面遇到了麻烦。当用户按下浏览器的后退按钮时,即使用户已注销,它也会返回到用户页面。
我的代码看起来像这样-它有错误,但是我不确定如何完成
class Logout:
web.header("Cache-Control",
"no-cache, max-age=0, must-revalidate, no-store")
def GET(self):
session.login=0
session.kill()
raise web.seeother('/')
任何帮助,将不胜感激。
我实际上正在寻找python代码,因为我不知道该“ web.header”将放置在哪里。
最佳答案
您将web.header指令放在类的实际GET和SET方法中。
因此,您的情况将是:
class Logout:
def GET(self):
web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
session.login=0
session.kill()
raise web.seeother('/')