mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-16 18:05:35 -04:00
fix: prevent stale SPA shell after container rebuild (#7344)
Co-authored-by: Docker User <user@example.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Michael Genson <genson.michael@gmail.com> Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
This commit is contained in:
@@ -33,14 +33,22 @@ class MetaTag:
|
|||||||
class SPAStaticFiles(StaticFiles):
|
class SPAStaticFiles(StaticFiles):
|
||||||
async def get_response(self, path: str, scope):
|
async def get_response(self, path: str, scope):
|
||||||
try:
|
try:
|
||||||
return await super().get_response(path, scope)
|
response = await super().get_response(path, scope)
|
||||||
except HTTPException as ex:
|
except HTTPException as ex:
|
||||||
if ex.status_code == 404:
|
if ex.status_code == 404:
|
||||||
return await super().get_response("index.html", scope)
|
response = await super().get_response("index.html", scope)
|
||||||
else:
|
else:
|
||||||
raise ex
|
raise ex
|
||||||
except Exception as e:
|
|
||||||
raise e
|
# Hashed assets (_nuxt/*) are safe to cache forever since new builds produce new filenames.
|
||||||
|
# HTML must revalidate so browsers always fetch the correct bundle references after a
|
||||||
|
# container rebuild (prevents blank white page from stale index.html in HA iframes, etc).
|
||||||
|
if path.startswith("_nuxt/"):
|
||||||
|
response.headers["Cache-Control"] = "public, max-age=31536000, immutable"
|
||||||
|
elif path == "." or response.media_type == "text/html":
|
||||||
|
response.headers["Cache-Control"] = "no-cache"
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
__app_settings = get_app_settings()
|
__app_settings = get_app_settings()
|
||||||
|
|||||||
Reference in New Issue
Block a user