fix: Add Cache-Control: no-cache to static files to prevent stale HTML/image caching

This commit is contained in:
2026-05-22 18:44:36 -04:00
parent 71a0c9936a
commit db6859a0f5
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -2417,4 +2417,10 @@ def list_all_service_entrances():
app.mount("/uploads", StaticFiles(directory=str(UPLOADS_DIR)), name="uploads")
if STATIC_DIR.exists():
app.mount("/", StaticFiles(directory=str(STATIC_DIR), html=True), name="static")
class NoCacheStaticFiles(StaticFiles):
async def get_response(self, path, scope):
resp = await super().get_response(path, scope)
# No-cache for all static assets (HTML, images, JS, CSS)
resp.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
return resp
app.mount("/", NoCacheStaticFiles(directory=str(STATIC_DIR), html=True), name="static")