Skip to content

Instantly share code, notes, and snippets.

@omarish
Created May 2, 2013 00:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save omarish/5499385 to your computer and use it in GitHub Desktop.
Save omarish/5499385 to your computer and use it in GitHub Desktop.
A Tornado StaticFileHandler to disable static asset caching when you're in debug mode. Thanks to @didip for https://gist.github.com/didip/902931.
import tornado.web
class NoCacheStaticFileHandler(tornado.web.StaticFileHandler):
def set_extra_headers(self, path):
self.set_header("Cache-control", "no-cache")
class Application(tornado.web.Application):
def __init__(self):
handlers = [
# ...
url(r"/static/(.*)",
tornado.web.StaticFileHandler if not options.debug else NoCacheStaticFileHandler, {
"path": '/var/www/static'
}, name="static")
@alejandrogallo
Copy link

nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment