Open masih opened 1 year ago
Cache-Control: max-age=5, stale-while-revalidate=300
provides a hint for Cloudflont and end HTTP clients on how long they should cache responsefor a specific CID
max-age
for 404s and 200s. max-age
than DHT ones. Cache-Control
with 404s allows IPNI to have more control over how long 404s should be cached by Cloudfront (see their docs). max-age
window geometrically (helps with UX problem described here):
Cache-Control: max-age=5, stale-while-revalidate=300
Cache-Control: max-age=30, stale-while-revalidate=300
Cache-Control: max-age=90, stale-while-revalidate=300
stale-while-revalidate
means check for updated result happens asynchronously, so re-checking 404s will not introduce latency to end userCache-Control
and Age
headers and make informed decision Retry-After
is usually only used for 429 and 503 as explicit hint for automated HTTP clients to perform a cooldown and wait between retries. It could be added in addition to Cache-Control
, but I feel both Cloudfront and Lassie care about the same max-age
, so we probably can do without this header in 404s.
My suggestion would be to start small:
Cache-Control: max-age=n, stale-while-revalidate=300
to 404s, and make n
grow from 5 seconds to 300 (geometric or exponential)Cache-Control
header is present in IPNI response, and if so, cache IPNI result for max-age
number of seconds, to avoid sending requests that would produce the same response from Cloudfront.If feel if we have this, we don't need Retry-After
.
In cases where 404s can potentially be satisfied in a later time, e.g. max internal timeout was hit, or 5 minutes caching of 404s, add extra headers to aid http clients make better decisions on retries.
See: