From 03597d37f0afd310ee6915fd18f3937a2080e3b7 Mon Sep 17 00:00:00 2001 From: mARTin-B78 Date: Tue, 22 Sep 2026 20:28:46 +0200 Subject: [PATCH] fix(release): keep index.html's cache-busting version tags in sync static/index.html hardcodes ?v= query strings on style.css, the per-page CSS files and loader.js, plus an app-version meta tag. Nothing kept them in sync with VERSION, so they'd silently drifted to different stale versions each (found live: style.css one release behind, loader.js sixteen releases behind). The static-file middleware marks any CSS/JS request with a ?v= query as max-age=31536000 immutable, so a browser that had ever loaded e.g. magazine.js?v=1.26.10 kept serving that exact response for a year no matter how many times the file changed on disk or how hard the page was force-reloaded. release.py now rewrites every ?v=X.Y.Z and the app-version meta tag to the new version on every release, so a release is what invalidates the cache rather than a manual, easy-to-forget edit. Co-Authored-By: Claude Sonnet 5 --- scripts/release.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index e2daf0f..aacdf7f 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -32,9 +32,31 @@ from pathlib import Path REPO_ROOT = Path(__file__).parent.parent VERSION_FILE = REPO_ROOT / "VERSION" CHANGELOG_FILE = REPO_ROOT / "CHANGELOG.md" +INDEX_HTML_FILE = REPO_ROOT / "static" / "index.html" GITHUB_REPO = "mARTin-B78/tts-voice-creator-clone-and-design-2" GITHUB_BASE = f"https://github.com/{GITHUB_REPO}" +# static/index.html hardcodes ?v= cache-busting query strings on style.css, +# the per-page CSS files and loader.js, plus an +# tag. Nothing previously kept these in sync with VERSION, so they silently +# drifted to different stale versions each (seen live: style.css one release +# behind, loader.js sixteen releases behind) -- StaticCacheHeadersMiddleware +# in server.py marks any *.css/js request WITH a ?v= query +# "Cache-Control: public, max-age=31536000, immutable", so once a browser +# had fetched e.g. magazine.js?v=1.26.10 it kept serving that exact response +# for a year regardless of how many times the file changed on disk or how +# hard the page was reloaded. Rewriting every ?v=X.Y.Z to the new version on +# every release is what actually invalidates that cache. +_VERSION_QUERY_RE = re.compile(r"(\?v=)\d+\.\d+\.\d+") +_APP_VERSION_META_RE = re.compile(r'( str: + html = INDEX_HTML_FILE.read_text() + html = _VERSION_QUERY_RE.sub(rf"\g<1>{new_str}", html) + html = _APP_VERSION_META_RE.sub(rf"\g<1>{new_str}\g<2>", html) + return html + def read_version() -> tuple[int, int, int]: text = VERSION_FILE.read_text().strip() @@ -124,13 +146,17 @@ def main() -> None: print(f" {line}") print() + index_html = bump_index_html(new_str) + if not dry: CHANGELOG_FILE.write_text(changelog) VERSION_FILE.write_text(new_str + "\n") + INDEX_HTML_FILE.write_text(index_html) print(f" ✓ Wrote VERSION → {new_str}") print(f" ✓ Wrote CHANGELOG.md") + print(f" ✓ Wrote static/index.html cache-busting tags → {new_str}") - git("add", "VERSION", "CHANGELOG.md") + git("add", "VERSION", "CHANGELOG.md", "static/index.html") git("commit", "--no-verify", "-m", f"Release v{new_str}") git("tag", "-a", f"v{new_str}", "-m", f"v{new_str}")