How does HTTP caching work for APIs, and what role do Cache-Control directives play?

Last updated 29 June 2026

  • Caching has two phases. A fresh copy is served with no network call. A stale copy is revalidated via ETag/If-None-Match or Last-Modified, often yielding a cheap 304.

  • Cache-Control sets the rules: max-age (freshness lifetime), public/private (shared vs client-only), no-cache/no-store, and must-revalidate.

  • For APIs, cache mainly GET responses, not mutations. Use Vary (e.g. on Accept or auth) so caches don't serve the wrong representation.

  • https://www.greatfrontend.com/blog/rest-api-interview-questions-for-frontend-devs
  • https://www.greatfrontend.com/blog/latest
  • https://interviewprepnotes.com/api-design
All REST API interview questions