MCPcopy Create free account
hub / github.com/psf/cachecontrol / ExpiresAfter

Class ExpiresAfter

cachecontrol/heuristics.py:80–94  ·  view source on GitHub ↗

Cache **all** requests for a defined time period.

Source from the content-addressed store, hash-verified

78
79
80class 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
97class LastModified(BaseHeuristic):

Callers 1

setup_methodMethod · 0.90

Calls

no outgoing calls

Tested by 1

setup_methodMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…