HTTP Caching 101

After repeatedly teaching the basics of HTTP caching in an ad-hoc fashion, I decided it was worth briefly summarizing the fundamental mechanisms.

Circumstances at the time meant that giving an internal presentation was incumbent, so I opted for an approach that steps through HTTP request/response cycles; slides work reasonably well for that.

The slide deck explains various scenarios and corresponding headers. It starts by introducing conditional GET requests (via Last-Modified/If-Modified-Since or ETag/If-None-Match), followed by resource expiry (via Expires or Cache-Control). From there, we can distinguish immutable from volatile resources and point out common patterns like stale and private resources.

Steve Souders’s Cache is King served as inspiration for this trimmed-down introduction (cf. slides 30 ff.; 00:10:41 in the video). Also worth reading are Jake Archibald’s Caching best practices & max-age gotchas along with Fastly’s real-world analysis in The headers we want and The headers we don’t want.