SVGHMI : avoid caching of xhtml file by forcing cache-control header in http response. svghmi
authorEdouard Tisserant
Tue, 21 Jan 2020 13:55:03 +0100
branchsvghmi
changeset 2830 15d7bd79d9e8
parent 2829 4c2c50f60730
child 2831 6c9cfdbe94dc
SVGHMI : avoid caching of xhtml file by forcing cache-control header in http response.
svghmi/svghmi.py
svghmi/svghmi_server.py
--- a/svghmi/svghmi.py	Fri Jan 17 16:25:45 2020 +0100
+++ b/svghmi/svghmi.py	Tue Jan 21 13:55:03 2020 +0100
@@ -516,7 +516,7 @@
     {svghmi_cmds[Watchdog]}
 
 def _runtime_svghmi1_{location}_start():
-    svghmi_root.putChild('{view_name}',File('{xhtml}', defaultType='application/xhtml+xml'))
+    svghmi_root.putChild('{view_name}', NoCacheFile('{xhtml}', defaultType='application/xhtml+xml'))
     {svghmi_cmds[Start]}
 
 def _runtime_svghmi1_{location}_stop():
--- a/svghmi/svghmi_server.py	Fri Jan 17 16:25:45 2020 +0100
+++ b/svghmi/svghmi_server.py	Tue Jan 21 13:55:03 2020 +0100
@@ -193,3 +193,11 @@
     svghmi_send_thread.join()
     svghmi_send_thread = None
 
+
+class NoCacheFile(File):
+    def render_GET(self, request):
+        request.setHeader(b"Cache-Control", b"no-cache, no-store")
+        return File.render_GET(self, request)
+    render_HEAD = render_GET
+
+