diff --git a/main.py b/main.py index dd7cdc6..d6c711b 100644 --- a/main.py +++ b/main.py @@ -138,7 +138,7 @@ MAX_MESSAGE_LEN = 10_000 # ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква). # Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version). -APP_VERSION = "2026-07-17s" +APP_VERSION = "2026-07-17t" # Audit: path → action name mapping _AUDIT_MAP = [ @@ -265,8 +265,24 @@ def _get_tab(request: Request, body: dict | None = None) -> str: @app.get("/", response_class=HTMLResponse) -async def index(): - return Path("static/chat.html").read_text(encoding="utf-8") +async def index(request: Request): + # Кэш-бастинг главной (как /admin): без актуального ?v= → 302 на URL с v=APP_VERSION + # (новый URL ≠ закэшированный без query → промах кэша → свежий запрос → no-store). + # Прочие параметры (?tab=) сохраняем. Иначе браузер держит старый chat.html навсегда. + from fastapi.responses import RedirectResponse + from urllib.parse import urlencode + if request.query_params.get("v") != APP_VERSION: + params = dict(request.query_params) + params["v"] = APP_VERSION + return RedirectResponse(url=f"/?{urlencode(params)}", status_code=302) + return HTMLResponse( + Path("static/chat.html").read_text(encoding="utf-8"), + headers={ + "Cache-Control": "no-store, no-cache, must-revalidate, max-age=0", + "Pragma": "no-cache", + "Expires": "0", + }, + ) @app.get("/api/version")