From 20887418f12fc07d869a6406071a8cce6ee3a37d Mon Sep 17 00:00:00 2001 From: rope Date: Tue, 20 Oct 2026 10:38:43 +0100 Subject: [PATCH] Versioned client URLs so no cache serves an old build Co-Authored-By: Claude Opus 5.5 --- app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app.py b/app.py index 32706fd..7911d7e 100644 --- a/app.py +++ b/app.py @@ -226,6 +226,10 @@ class Handler(BaseHTTPRequestHandler): if STATIC_DIR.resolve() not in target.parents or not target.is_file(): target = STATIC_DIR / "index.html" body = target.read_bytes() + if target.name == "index.html": + # Versioned URLs, so no cache (a home-screen app's included) can serve an old client. + for asset in (b"/static/app.js", b"/static/styles.css"): + body = body.replace(asset + b'"', asset + b"?v=" + VERSION.encode() + b'"') self.send_response(HTTPStatus.OK) self.send_header("Content-Type", mimetypes.guess_type(target.name)[0] or "application/octet-stream") self.send_header("Content-Length", str(len(body)))