How do you keep content fresh at the edge: a short TTL, a purge, or versioned file names?
Sketch your own answer first, then compare it with the one below.
A strong answer
A short TTL is the simplest. It bounds staleness and sends more traffic to the origin all the time.
A purge deletes copies when the content changes. You keep a long TTL and still get fresh content. The cost is an extra system that must reach every cache, and a purge that misses one edge leaves an old copy there until its TTL ends. Keep a TTL as a safety net.
Versioned names put a hash in the file name. A new version is a new key, so the old copy can be cached for a very long time and never needs a purge. It fits files that pages reference. It does not fit the page itself, which needs a fixed address.
Sources
- Roy Fielding, Mark Nottingham, Julian Reschke (2022). RFC 9111: HTTP Caching.