I'm using a bottle webserver in python. When I am debugging, I want to make changes to the pseudo-html template files and then reload the page to see it in the browser. It seems that bottle caches the template files and I can't get them to load from the newly-modified template.
Here's my situation:
First approach
Second approach
I have forced the browser to request the file a second time (not using its own cache) and, via a python debugger (PyCharm), I can see that the bottle webserver is at least pretending to go through the motions of doing all of the things it is supposed to do with a template file.
From http://bottlepy.org/docs/dev/stpl.html#bottle.SimpleTemplate
Just keep in mind that compiling and rendering templates are two different actions, even if the template() helper hides this fact. Templates are usually compiled only once and cached internally, but rendered many times with different keyword arguments.
But http://bottlepy.org/docs/dev/tutorial.html#templates states:
Caching
Templates are cached in memory after compilation. Modifications made to the template files will have no affect until you clear the template cache. Call
bottle.TEMPLATES.clear()
to do so. Caching is disabled in debug mode.
Which you could find at http://bottlepy.org/docs/dev/tutorial.html#debug-mode
bottle.debug(True)
In this mode, Bottle is much more verbose and provides helpful debugging information whenever an error occurs. It also disables some optimisations that might get in your way and adds some checks that warn you about possible misconfiguration.
Here is an incomplete list of things that change in debug mode:
The default error page shows a traceback.
Templates are not cached.
Plugins are applied immediately.
If that still doesn't help, a bit of browsing turns up https://github.com/bottlepy/bottle/blob/master/bottle.py#L3937
class SimpleTemplate(BaseTemplate):
def prepare(self,
escape_func=html_escape,
noescape=False,
syntax=None, **ka):
self.cache = {}
...
which seems to clear the cache.