Skip to content

Versioning & Caching

Two forces shape a long-lived API: it must change without breaking the clients already using it, and it should be fast, ideally by not doing work it has already done. Versioning addresses the first; HTTP caching addresses the second.

flowchart TD
  API --> V[Versioning: evolve safely]
  API --> Cn[Content negotiation: pick a representation]
  API --> Ca[Caching: avoid repeating work]
  V --> V1[URI / header / media-type]
  Ca --> Ca1[Cache-Control + ETag + conditional requests]
Evolving the contract and serving it efficiently

These are related: caching depends on stable representations, and versioning decides what those representations look like over time.

  • Versioning strategies — URI, header, and media-type versioning.
  • Content negotiation — choosing a representation with Accept.
  • Caching & ETagsCache-Control, validators, and 304 Not Modified.
  • Conditional requests & idempotency keys — safe writes and retries.
Which kind of change usually does NOT require a new API version?
HTTP caching primarily helps an API by: