From 2d3ebfefd539f0ca13ba824b877d71ebbc95d44f Mon Sep 17 00:00:00 2001 From: calesthio Date: Fri, 10 Jul 2026 15:56:25 -0700 Subject: [PATCH] fix(backlot): no-cache header for UI pages and assets The board is a long-lived SPA tab; browsers heuristically cache /ui assets, so UI fixes did not show up on plain refresh. Cache-Control: no-cache forces conditional revalidation (cheap ETag 304s) for /, /p/*, and /ui/* while leaving media and thumbnail caching untouched. --- backlot/server.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backlot/server.py b/backlot/server.py index f2220d14..93ee7fc4 100644 --- a/backlot/server.py +++ b/backlot/server.py @@ -277,6 +277,18 @@ def create_app() -> FastAPI: if UI_DIR.is_dir(): app.mount("/ui", StaticFiles(directory=UI_DIR), name="ui") + # The board is a long-lived SPA: a tab keeps running whatever board.js it + # loaded, and browsers heuristically cache /ui assets. no-cache forces a + # conditional revalidation (cheap 304 via ETag) on every load so UI fixes + # show up on a plain refresh. Media/thumb responses keep normal caching. + @app.middleware("http") + async def ui_no_cache(request, call_next): + response = await call_next(request) + path = request.url.path + if path == "/" or path.startswith("/ui") or path.startswith("/p/"): + response.headers["Cache-Control"] = "no-cache" + return response + return app