Cache the response by providing an expires 1 day in the future.
| 58 | |
| 59 | |
| 60 | class OneDayCache(BaseHeuristic): |
| 61 | """ |
| 62 | Cache the response by providing an expires 1 day in the |
| 63 | future. |
| 64 | """ |
| 65 | |
| 66 | def update_headers(self, response: HTTPResponse) -> dict[str, str]: |
| 67 | headers = {} |
| 68 | |
| 69 | if "expires" not in response.headers: |
| 70 | date = parsedate(response.headers["date"]) |
| 71 | expires = expire_after( |
| 72 | timedelta(days=1), |
| 73 | date=datetime(*date[:6], tzinfo=timezone.utc), # type: ignore[index,misc] |
| 74 | ) |
| 75 | headers["expires"] = datetime_to_header(expires) |
| 76 | headers["cache-control"] = "public" |
| 77 | return headers |
| 78 | |
| 79 | |
| 80 | class ExpiresAfter(BaseHeuristic): |
no outgoing calls
searching dependent graphs…