Skip to content

Commit 31bde6c

Browse files
zmqserver: Do not cache local files
1 parent 83cf73b commit 31bde6c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/meshcat/servers/zmqserver.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ def create_command(data):
8080
""".format(base64.b64encode(data).decode("utf-8"))
8181

8282

83+
class StaticFileHandlerNoCache(tornado.web.StaticFileHandler):
84+
"""Ensures static files do not get cached.
85+
86+
Taken from: https://stackoverflow.com/a/18879658/7829525
87+
"""
88+
def set_extra_headers(self, path):
89+
# Disable cache
90+
self.set_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
91+
92+
8393
class ZMQWebSocketBridge(object):
8494
context = zmq.Context()
8595

@@ -107,7 +117,7 @@ def f(port):
107117

108118
def make_app(self):
109119
return tornado.web.Application([
110-
(r"/static/(.*)", tornado.web.StaticFileHandler, {"path": VIEWER_ROOT, "default_filename": VIEWER_HTML}),
120+
(r"/static/(.*)", StaticFileHandlerNoCache, {"path": VIEWER_ROOT, "default_filename": VIEWER_HTML}),
111121
(r"/", WebSocketHandler, {"bridge": self})
112122
])
113123

0 commit comments

Comments
 (0)