feat: cache-control overhaul so visual changes propagate immediately
CI / Lint (push) Successful in 14s
CI / Test (push) Successful in 12s
CI / Build & Push (push) Successful in 32s

Per-file content-hash versioning on every /static reference, immutable cache
headers on versioned URLs, no-cache on HTML, auto-bumped service worker cache
name with stale-while-revalidate for assets, and a controllerchange listener
that silently reloads the page when a new SW takes control.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 20:11:36 -04:00
parent aaa0899506
commit 7d1649d278
7 changed files with 110 additions and 27 deletions
+13 -3
View File
@@ -1,8 +1,8 @@
import json
from flask import abort, render_template, jsonify, send_from_directory
from flask import abort, make_response, render_template, jsonify, send_from_directory
from app import app
from app import APP_VERSION, app, static_v
from app.config import SCOREBOARD_DATA_FILE
from app.games import parse_games
from app.playoff import today_meta
@@ -39,7 +39,17 @@ def manifest():
@app.route("/sw.js")
def service_worker():
response = send_from_directory(app.static_folder, "sw.js")
precache = [
"/",
static_v("styles.css"),
static_v("script.js"),
static_v("icon-192x192.png"),
static_v("icon-512x512.png"),
"/manifest.json",
]
body = render_template("sw.js.j2", app_version=APP_VERSION, precache=precache)
response = make_response(body)
response.headers["Content-Type"] = "application/javascript; charset=utf-8"
response.headers["Service-Worker-Allowed"] = "/"
response.headers["Cache-Control"] = "no-cache"
return response