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

Class OneDayCache

cachecontrol/heuristics.py:60–77  ·  view source on GitHub ↗

Cache the response by providing an expires 1 day in the future.

Source from the content-addressed store, hash-verified

58
59
60class 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
80class ExpiresAfter(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…