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

@@ -76,7 +76,7 @@
</div>
<script src="/assets/maplibre-gl.js"></script>
<script src="/s52_runtime_executor.js"></script>
<script src="/s52_runtime_executor.js?v=ca-geometry-v1"></script>
<script>
const REFERENCE_STYLE =
"https://pbf.jpcn.ccwu.cc/style/style.navsea-delivery-full-semantic-extentfix.json";
@@ -691,7 +691,7 @@ function prepareS52Style(raw){
async function ensureS52StyleTemplate(){
if(s52StyleTemplate)return s52StyleTemplate;
const response=await fetch("/s52/full-style.json",{cache:"no-store"});
const response=await fetch("/s52/full-style.json?v=current-release",{cache:"no-store"});
if(!response.ok)throw new Error("S-52 full style HTTP " + response.status);
s52StyleTemplate=await response.json();
return s52StyleTemplate;

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 (