Правка кеширования данных сайта

This commit is contained in:
2026-06-26 23:06:04 +03:00
parent 6d75b4c130
commit f56f9eb47b
2 changed files with 21 additions and 8 deletions
+5 -1
View File
@@ -208,9 +208,13 @@ def _mount_spa(app: FastAPI) -> None:
full_path
and _STATIC_DIR in candidate.parents
and candidate.is_file()
and candidate.name != "index.html"
):
# Хэшированные ассеты Vite — обычное кэширование (имя меняется при сборке).
return FileResponse(candidate)
return FileResponse(index_file)
# index.html (корень и SPA-маршруты) — НЕ кэшируем: иначе браузер отдаёт старый
# документ из кэша и при недоступности хоста не доходит до Caddy с заглушкой.
return FileResponse(index_file, headers={"Cache-Control": "no-store"})
app = create_app()