fix: no-cache headers on JS/CSS + version query params to bust browser cache

This commit is contained in:
root
2026-07-16 11:16:21 +00:00
parent 92291be2b1
commit 046e8be14b
5 changed files with 8 additions and 4 deletions

View File

@@ -840,5 +840,9 @@ async def serve_static(path: str):
"""Serve static files or return index.html for SPA routes."""
file_path = static_dir / path
if file_path.exists() and file_path.is_file():
return FileResponse(str(file_path))
response = FileResponse(str(file_path))
# Prevent caching of JS/CSS so code changes take effect without hard refresh
if path.endswith(('.js', '.css')):
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
return response
return FileResponse(str(static_dir / "index.html"))