fix: no-cache headers on JS/CSS + version query params to bust browser cache
This commit is contained in:
6
main.py
6
main.py
@@ -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"))
|
||||
Reference in New Issue
Block a user