Jor*_*dan 24 python caching tornado static-files
默认情况下,Tornado会在a Cache-Control: public提供的任何文件上放置标题StaticFileHandler.怎么能改成Cache-Control: no-cache?
0xd*_*d00 42
接受的答案不适用于Chrome.子类StaticFileHandler使用以下内容:
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')
Run Code Online (Sandbox Code Playgroud)
小智 14
查看tornado/web.py似乎最简单的方法是子类化StaticFileHandler并覆盖set_extra_headers方法.
def set_extra_headers(self, path):
self.set_header("Cache-control", "no-cache")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8704 次 |
| 最近记录: |