【发布时间】:2015-06-27 20:55:51
【问题描述】:
这里有一个类似的问题,但答案已经超过 2 年了,我无法让它发挥作用。如果我遗漏了什么 - 请告诉我。
Bottle.py caching templates despite being in debug mode
每当浏览器指向 0.0.0.0:8080/16boxes 时,我都需要阻止缓存。 Bottle 文档说当处于调试模式时,缓存被禁用,但不幸的是我不是这种情况。
这是我的 hello.py 代码:
@route('/16boxes')
def send_static():
response.set_header('Cache-control', 'no-cache, must-revalidate')
return template (resource_path('16boxes.html'), globalVar0 = globalVar0)
run(host='0.0.0.0', port=8080, debug=True)
我打开终端并运行:python hello.py
当我在 Mac/Chrome 上运行它时它不会缓存 - 但当我使用 Windows 和 Internet Explorer 时 - 它使用缓存版本。我怎样才能防止这种情况发生?
在我的 16boxes.html 中,我什至有以下内容:
<meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Pragma" content="no-cache">
【问题讨论】:
-
更改文件时应用程序是否会重新加载?
-
不,只有当我清除浏览器中的缓存时。
标签: python html caching server bottle