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:
parent
61d8b2fce3
commit
20887418f1
1 changed files with 4 additions and 0 deletions
4
app.py
4
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)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue