From d4b0d21ed14d2923db7759c47a0777acaf844bd0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 14 May 2026 02:24:58 +0000 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20no-cache=20Header=20f=C3=BCr?= =?UTF-8?q?=20Static-Files=20und=20Index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browser haben nach Deploys die alten app.js / style.css aus dem Cache weiterbenutzt. Mit Cache-Control: no-cache, must-revalidate wird bei jeder Anfrage revalidiert (304 wenn unverändert, 200 wenn neu). --- lxc-frontend/app/main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lxc-frontend/app/main.py b/lxc-frontend/app/main.py index 6f7f339..eecfff1 100644 --- a/lxc-frontend/app/main.py +++ b/lxc-frontend/app/main.py @@ -5,12 +5,22 @@ from pathlib import Path from fastapi import FastAPI from fastapi.responses import FileResponse, JSONResponse from fastapi.staticfiles import StaticFiles +from starlette.types import Scope from app.api.jobs import router as jobs_router from app.core.config import settings from app.core.db import init_db from app.core.mac_client import MacClient + +class NoCacheStaticFiles(StaticFiles): + """StaticFiles, die Browser zu Revalidierung zwingen (verhindert hängende Caches nach Deploy).""" + + async def get_response(self, path: str, scope: Scope): + response = await super().get_response(path, scope) + response.headers["Cache-Control"] = "no-cache, must-revalidate" + return response + logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(name)s: %(message)s") log = logging.getLogger("voice-agent") @@ -29,12 +39,12 @@ app = FastAPI(title=settings.app_name, lifespan=lifespan) app.include_router(jobs_router) STATIC_DIR = Path(__file__).resolve().parent / "static" -app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static") +app.mount("/static", NoCacheStaticFiles(directory=STATIC_DIR), name="static") @app.get("/") def index(): - return FileResponse(STATIC_DIR / "index.html") + return FileResponse(STATIC_DIR / "index.html", headers={"Cache-Control": "no-cache, must-revalidate"}) @app.get("/health")