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.
This commit is contained in:
calesthio
2026-07-10 15:56:25 -07:00
parent d3a8fcf3bc
commit 2d3ebfefd5

View File

@@ -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