INNER CODE UNIT · Python
get_response
Duelion/homebox-companion · server/app.py:220
async def get_response(self, path: str, scope) -> Response:
response = await super().get_response(path, scope)
# index.html and root: always revalidate
#
# service-worker.js must also always revalidate:
# - browsers may cache the SW script itself
# - if cached, clients can stay stuck on old SW logic for up to the TTL
#
# manifest.json is also frequently cached by browsers/PWA install flows.
if path in ("", "index.html", "service-worker.js", "manifest.json") or path.endswith("/index.html"):
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "0"
# Immutable hashed assets: cache forever
elif "/_app/immutable/" in f"/{path}" or path.startswith("_app/immutable/"):
response.headers["Cache-Control"] = "public, max-age=31536000, immutable"
# Other static assets (icons, manifest, etc.): cache for 1 hour