问题
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
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.
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)
I open up terminal and run: python hello.py
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?
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">
回答1:
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.
来源:https://stackoverflow.com/questions/29759636/bottle-framework-caches-my-template-even-in-debug-mode