fix: disable stale cache for Kyushu web runtime

This commit is contained in:
OpenAI Codex
2026-09-21 17:55:02 +08:00
parent 30f6bacef2
commit 9a10e59d6c
2 changed files with 15 additions and 6 deletions

View File

@@ -58,11 +58,13 @@ def main():
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
class Handler(BaseHTTPRequestHandler):
def send_bytes(self, data: bytes, content_type: str, status: int = 200):
def send_bytes(
self, data: bytes, content_type: str, status: int = 200, *, cache_control: str = "no-cache"
):
self.send_response(status)
self.send_header("Content-Type", content_type)
self.send_header("Content-Length", str(len(data)))
self.send_header("Cache-Control", "no-cache")
self.send_header("Cache-Control", cache_control)
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers()
self.wfile.write(data)
@@ -71,13 +73,16 @@ def main():
path = urlparse(self.path).path
if path in ("/", "/index.html", "/compare"):
self.send_bytes(html_path.read_bytes(), "text/html; charset=utf-8")
self.send_bytes(
html_path.read_bytes(), "text/html; charset=utf-8", cache_control="no-store"
)
return
if path == "/s52_runtime_executor.js":
self.send_bytes(
runtime_executor_path.read_bytes(),
"application/javascript; charset=utf-8",
cache_control="no-store",
)
return
@@ -100,7 +105,11 @@ def main():
return
if path == "/s52/full-style.json":
self.send_bytes(s52_style_path.read_bytes(), "application/json; charset=utf-8")
self.send_bytes(
s52_style_path.read_bytes(),
"application/json; charset=utf-8",
cache_control="no-store",
)
return
if path in (