fix: Add Cache-Control: no-cache to static files to prevent stale HTML/image caching
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user