Versioned client URLs so no cache serves an old build

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-20 10:38:43 +01:00
parent 61d8b2fce3
commit 20887418f1

4
app.py
View file

@ -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)))