📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials API Design HTTP Caching

HTTP Caching

5 min read
Cache-Control, ETags, and conditional requests reduce server load and latency for GET-heavy APIs.

HTTP Caching

# Cache-Control headers
Cache-Control: public, max-age=300   # cache 5 min
Cache-Control: private, max-age=60   # browser only
Cache-Control: no-store              # never cache

# ETag (conditional requests)
ETag: "abc123"

GET /api/posts
If-None-Match: "abc123"
# 304 Not Modified if content unchanged

# Route caching strategy
# GET /posts    -> Cache-Control: public, max-age=60
# GET /me       -> Cache-Control: private, no-store
# POST/PUT      -> never cache