From db6859a0f5bf62229cd6f6cb685a1e6380c81d13 Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 22 May 2026 18:44:36 -0400 Subject: [PATCH] fix: Add Cache-Control: no-cache to static files to prevent stale HTML/image caching --- server.py | 8 +++++++- static/index.html | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index c871079..8b0e768 100644 --- a/server.py +++ b/server.py @@ -2417,4 +2417,10 @@ def list_all_service_entrances(): app.mount("/uploads", StaticFiles(directory=str(UPLOADS_DIR)), name="uploads") if STATIC_DIR.exists(): - app.mount("/", StaticFiles(directory=str(STATIC_DIR), html=True), name="static") + class NoCacheStaticFiles(StaticFiles): + async def get_response(self, path, scope): + resp = await super().get_response(path, scope) + # No-cache for all static assets (HTML, images, JS, CSS) + resp.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" + return resp + app.mount("/", NoCacheStaticFiles(directory=str(STATIC_DIR), html=True), name="static") diff --git a/static/index.html b/static/index.html index b5b898e..145a871 100644 --- a/static/index.html +++ b/static/index.html @@ -3126,7 +3126,7 @@ // ── Category config ─────────────────────────────────────────────────── const CATEGORY_MAP = { 'Bev': { icon: '🥤', color: '#0a7ab5' }, - 'Snack': { icon: '', color: '#c97d0e' }, + 'Snack': { icon: '', color: '#c97d0e' }, 'Gf bev': { icon: '🧃', color: '#0a9e5a' }, 'Gf food': { icon: '🥪', color: '#8a5c2a' }, 'Other': { icon: '📦', color: '#6b7280' },