Cache **all** requests for a defined time period.
| 78 | |
| 79 | |
| 80 | class ExpiresAfter(BaseHeuristic): |
| 81 | """ |
| 82 | Cache **all** requests for a defined time period. |
| 83 | """ |
| 84 | |
| 85 | def __init__(self, **kw: Any) -> None: |
| 86 | self.delta = timedelta(**kw) |
| 87 | |
| 88 | def update_headers(self, response: HTTPResponse) -> dict[str, str]: |
| 89 | expires = expire_after(self.delta) |
| 90 | return {"expires": datetime_to_header(expires), "cache-control": "public"} |
| 91 | |
| 92 | def warning(self, response: HTTPResponse) -> str | None: |
| 93 | tmpl = "110 - Automatically cached for %s. Response might be stale" |
| 94 | return tmpl % self.delta |
| 95 | |
| 96 | |
| 97 | class LastModified(BaseHeuristic): |
no outgoing calls
searching dependent graphs…