Flask-后退按钮即使在注销后也可以返回会话
问题描述:
我正在使用Flask创建一个需要登录和注销的网站.我正在使用Flask-Security来解决这个问题.我的问题是,注销后,如果单击后退"按钮,则会返回到用户页面.是否可以通过按Flask中的后退"按钮来防止注销后返回会话?
I am creating a website using flask that requires logging in and out. I am using Flask-Security to help with this. My problem is that after I log out, if I hit the back button, I return to the user's page. Is there a way to prevent returning to a session after logging out by pressing the back button in Flask?
答
使用 Cache-Control
标头可防止页面被缓存.
Use the Cache-Control
header to prevent a page from being cached.
response.headers.add('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0')