Gets the response for a requested path, adding no-cache headers. Args: path: The path to the static file requested. scope: The ASGI scope dictionary for the request. Returns: A Starlette Response object with cache-control headers modifie
(self, path: str, scope: Dict[str, Any])
| 81 | that prevent browsers from caching static assets. Useful for development. |
| 82 | """ |
| 83 | async def get_response(self, path: str, scope: Dict[str, Any]) -> Response: |
| 84 | """ |
| 85 | Gets the response for a requested path, adding no-cache headers. |
| 86 | |
| 87 | Args: |
| 88 | path: The path to the static file requested. |
| 89 | scope: The ASGI scope dictionary for the request. |
| 90 | |
| 91 | Returns: |
| 92 | A Starlette Response object with cache-control headers modified. |
| 93 | """ |
| 94 | response: Response = await super().get_response(path, scope) |
| 95 | response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0" |
| 96 | # These might not be strictly necessary with no-store, but belt and suspenders |
| 97 | if "etag" in response.headers: |
| 98 | response.headers.__delitem__("etag") |
| 99 | if "last-modified" in response.headers: |
| 100 | response.headers.__delitem__("last-modified") |
| 101 | return response |
| 102 | |
| 103 | # -------------------------------------------------------------------- |
| 104 | # Lifespan management |
nothing calls this directly
no outgoing calls
no test coverage detected