HTTP freshness lifetime
ID: http-freshness-lifetime
The HTTP freshness lifetime is the duration against which an HTTP response's HTTP current age is compared to determine HTTP freshness. It can be specified explicitly or, where allowed, estimated by a cache. It is not the same as the amount of fresh time remaining: that depends on the response's current age as well.[ref]
For valid explicit metadata, the RFC applies the first relevant rule. An HTTP shared cache uses
s-maxage when present; otherwise max-age applies. If neither applicable directive is present, Expires supplies an expiration time from which the response's Date is subtracted, with the specified receipt-time fallback when Date is absent. Only when there is no explicit expiration time can HTTP heuristic freshness be applicable.[ref]Consider a response with
Cache-Control: max-age=600, s-maxage=60. An HTTP shared cache, which serves more than one user, takes a -second lifetime. An HTTP private cache, dedicated to one user, uses seconds instead. Assume the response otherwise satisfies the relevant storage and reuse rules.[ref]At current age seconds, the shared cache has seconds until its freshness boundary, while the private cache has . At age , the shared response is no longer fresh because is false; the private cache's comparison still succeeds. These are two cache policies for the same response metadata, not conflicting estimates of the response's age.
HTTP heuristic freshness is constrained estimation, not an instruction to assign every response an arbitrary lifetime. The RFC allows heuristics under specified conditions and does not prescribe one universal estimation algorithm.[ref]
Finally, a computed lifetime does not override every other directive. Conflicting controls require the restrictive handling specified by the RFC; a freshness calculation also does not force a user agent to refresh its visible page. The lifetime governs cache operation, while the complete reuse decision still depends on the request and applicable response rules.[ref]
New to topics? Read the docs here!