diff --git a/backend/main.py b/backend/main.py index ac1cf95..8dda82b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -52,8 +52,12 @@ async def spa(full_path: str): ) candidate = (DIST / full_path).resolve() if full_path else None if candidate and candidate.is_file() and candidate.is_relative_to(DIST.resolve()): - return FileResponse(candidate) - return FileResponse(DIST / "index.html") + # hashed assets are immutable; cache them hard + headers = {"Cache-Control": "public, max-age=31536000, immutable"} \ + if full_path.startswith("assets/") else {"Cache-Control": "no-cache"} + return FileResponse(candidate, headers=headers) + # index.html must always revalidate, or phones keep showing stale builds + return FileResponse(DIST / "index.html", headers={"Cache-Control": "no-cache"}) # Catch-all WS route so the charger may dial any path (it uses /).