【发布时间】:2020-04-24 16:04:01
【问题描述】:
我创建了一个仅在本地运行并用于填写表单的烧瓶 Web 应用程序。填写表格后,它会自动将其记录在 Excel 文件中并发送电子邮件。由于应用程序保持 24/7,我想知道网络浏览器的缓存如何使我的程序崩溃?我没有在任何地方编写代码说明使用浏览器的缓存,但我担心这可能是我需要考虑的事情,因为我发现它会影响以前创建过网络应用程序的人。所以我想知道在我的情况下缓存如何使我的程序崩溃?用户只需输入他们的姓名并填写对问题的回答。
我已在我的 routes.py 中放置了以下代码,但我仍然看到浏览器保存了用户名,所以我认为它没有清除缓存:
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r
【问题讨论】:
标签: flask browser-cache flask-wtforms