Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable static file caching in Tornado

By default, Tornado puts a Cache-Control: public header on any file served by a StaticFileHandler. How can this be changed to Cache-Control: no-cache?

like image 766
Jordan Avatar asked Aug 20 '12 00:08

Jordan


1 Answers

The accepted answer does not work for Chrome. Subclass StaticFileHandler using the following:

class MyStaticFileHandler(tornado.web.StaticFileHandler):     def set_extra_headers(self, path):         # Disable cache         self.set_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') 
like image 111
0xdabbad00 Avatar answered Oct 02 '22 16:10

0xdabbad00