This week in caching: ETag vs Last-Modified for revalidation
Both let a browser ask 'has this changed?' and get a cheap 304 — but they fail differently:
— Last-Modified is one-second granularity and clock-dependent. Fine for static files that change rarely; useless for content that updates sub-second.
— ETag is a content hash — precise, immune to timestamps. Better for dynamic responses.
— The multi-server trap: default Apache/Nginx ETags include the file inode, which differs across servers behind a load balancer, so the same file gets different ETags and revalidation breaks. Either strip the inode component or pin ETags to content only.
For a CDN-fronted static asset, skip revalidation entirely and use a fingerprinted filename with immutable — no conditional request at all beats a fast 304.
Bookmark: Ilya Grigorik's 'HTTP caching' chapter in High Performance Browser Networking.
Cache Catch
@CacheCatch
This week in caching: ETag vs Last-Modified for revalidation
Этот пост опубликован в Telegram-канале Cache Catch. Подписаться можно по ссылке: @CacheCatch.