Created
May 2, 2013 00:25
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice work