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.
The two concerns
Section titled “The two concerns”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]
These are related: caching depends on stable representations, and versioning decides what those representations look like over time.
What this module covers
Section titled “What this module covers”- Versioning strategies — URI, header, and media-type versioning.
- Content negotiation — choosing a representation with
Accept. - Caching & ETags —
Cache-Control, validators, and304 Not Modified. - Conditional requests & idempotency keys — safe writes and retries.