This week in caching: a cache-policy checklist for an image CDN
Get images cached once and served forever. Gold for media-heavy sites.
— Cache-key on the transform, not the source — width, format, and quality params should be part of the key so ?w=400&format=webp caches distinctly from the original.
— Normalize param order — ?w=400&q=80 and ?q=80&w=400 must hit the same object; sort params at the edge or you double your storage.
— Vary on Accept for format negotiation — serving AVIF/WebP by Accept header needs a careful Vary: Accept, or you cache a WebP and feed it to a browser that can't read it.
— Long max-age, immutable — derivatives never change; max-age=31536000, immutable.
— Purge the source's derivatives together — re-uploading an image must invalidate every cached size and format via a shared tag.
Credit to the Cloudinary and imgix docs for the param-normalization rules.
Bookmark: the Vary: Accept + content-negotiation notes in MDN — the format-mismatch trap.
Cache Catch
@CacheCatch
This week in caching: a cache-policy checklist for an image CDN
Этот пост опубликован в Telegram-канале Cache Catch. Подписаться можно по ссылке: @CacheCatch.