fix: disable stale cache for Kyushu web runtime
This commit is contained in:
@@ -76,7 +76,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/maplibre-gl.js"></script>
|
<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>
|
<script>
|
||||||
const REFERENCE_STYLE =
|
const REFERENCE_STYLE =
|
||||||
"https://pbf.jpcn.ccwu.cc/style/style.navsea-delivery-full-semantic-extentfix.json";
|
"https://pbf.jpcn.ccwu.cc/style/style.navsea-delivery-full-semantic-extentfix.json";
|
||||||
@@ -691,7 +691,7 @@ function prepareS52Style(raw){
|
|||||||
|
|
||||||
async function ensureS52StyleTemplate(){
|
async function ensureS52StyleTemplate(){
|
||||||
if(s52StyleTemplate)return s52StyleTemplate;
|
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);
|
if(!response.ok)throw new Error("S-52 full style HTTP " + response.status);
|
||||||
s52StyleTemplate=await response.json();
|
s52StyleTemplate=await response.json();
|
||||||
return s52StyleTemplate;
|
return s52StyleTemplate;
|
||||||
|
|||||||
@@ -58,11 +58,13 @@ def main():
|
|||||||
|
|
||||||
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
||||||
class Handler(BaseHTTPRequestHandler):
|
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_response(status)
|
||||||
self.send_header("Content-Type", content_type)
|
self.send_header("Content-Type", content_type)
|
||||||
self.send_header("Content-Length", str(len(data)))
|
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.send_header("Access-Control-Allow-Origin", "*")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(data)
|
self.wfile.write(data)
|
||||||
@@ -71,13 +73,16 @@ def main():
|
|||||||
path = urlparse(self.path).path
|
path = urlparse(self.path).path
|
||||||
|
|
||||||
if path in ("/", "/index.html", "/compare"):
|
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
|
return
|
||||||
|
|
||||||
if path == "/s52_runtime_executor.js":
|
if path == "/s52_runtime_executor.js":
|
||||||
self.send_bytes(
|
self.send_bytes(
|
||||||
runtime_executor_path.read_bytes(),
|
runtime_executor_path.read_bytes(),
|
||||||
"application/javascript; charset=utf-8",
|
"application/javascript; charset=utf-8",
|
||||||
|
cache_control="no-store",
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -100,7 +105,11 @@ def main():
|
|||||||
return
|
return
|
||||||
|
|
||||||
if path == "/s52/full-style.json":
|
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
|
return
|
||||||
|
|
||||||
if path in (
|
if path in (
|
||||||
|
|||||||
Reference in New Issue
Block a user