Bottle框架即使在调试模式下也可以缓存我的模板 [英] Bottle framework caches my template even in debug mode
问题描述
这里也有类似的问题,但答案已有2年以上了,我无法解决.如果我缺少某些内容-请让我知道.
即使处于调试模式,Bottle.py缓存模板
There's a similar question on here, but the answers are over 2 years old and I can't get it to work. If I'm missing something - please let me know.
Bottle.py caching templates despite being in debug mode
每当浏览器指向0.0.0.0:8080/16boxes时,我就需要防止缓存.Bottle的文档说,在调试"模式下,缓存被禁用,但不幸的是,对我而言并非如此.
Whenever the browser points to 0.0.0.0:8080/16boxes, I need to prevent caching. The Bottle docs say when in Debug mode, caching is disabled, but that isn't the case for me unfortunately.
这是我有问题的hello.py代码:
Here is my hello.py code in question:
@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上运行时,它会使用缓存的版本.我该如何预防?
It doesn't cache when I run it on my Mac/Chrome - but when I use Windows and Internet Explorer - it uses a cached version. How can I prevent this?
在我的16boxes.html中,我甚至包含以下内容:
In my 16boxes.html, I even have the following in my :
<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">
推荐答案
您的问题是,由于浏览器缓存而加载页面时,您的JavaScript onload事件不会触发,
Your problem is that your JavaScript onload event doesn't fire when the page loads as a result of browser caching, jQuery's ready event was created for just this sort of issue.
这篇关于Bottle框架即使在调试模式下也可以缓存我的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!