When a Response Can Be Reused from a Cache

A cache can reuse stored HTTP responses when its matching, freshness, and privacy rules allow it.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a freshness decision
  2. Choose what identifies a representation
  3. Compare freshness and validation in one timeline
  4. Keep personalization and variants within the documented scope

Trace a freshness decision

A representation may be reusable for a bounded duration. Afterward a cache can check with the origin under the protocol. HTTP cache validators explain how the origin can say that stored content remains valid.

Choose what identifies a representation

Different language preferences can produce different representations for one path. The cache must account for the relevant request fields. A cache key expresses the general dependency rule.[1]

Compare freshness and validation in one timeline

A shared or private cache can reuse a fresh stored representation according to its directives and key. Once stale, it may validate with the origin before reusing it. A valid response to one variant can be wrong for a different request. See HTTP request metadata.

t=0: public resource fetched with a freshness lifetime of 60 s
t=30: eligible fresh response can be reused
t=70: validation may be required before reuse
A 304 can update metadata for the matched representation

Keep personalization and variants within the documented scope

A cache must honor directives about storing and reusing responses. A representation selected by request headers can require variant-aware keys. Test two variants and a stale stored response.

References

  1. IETF, RFC 9111: HTTP Caching ↩