Set cache headers that actually stick
Misconfigured caching forces re-downloads and re-validation round-trips that bloat TTFB on repeat views.
— Step 1: Hashed static assets (app.8f3a.js): Cache-Control: public, max-age=31536000, immutable. Never revalidate.
— Step 2: HTML: no-cache (revalidate) or short s-maxage at the edge with stale-while-revalidate.
— Step 3: Confirm with curl -I — look for the header AND an edge HIT (cf-cache-status / x-cache).
— Step 4: Add ETag only where content truly varies; a bad ETag forces 304 round-trips.
— Step 5: Re-measure repeat-view TTFB.
Before | After: repeat-view TTFB 380ms -> 60ms once immutable hit.
Takeaway: immutable static assets should serve at 0ms revalidation on repeat views.
Millisecond Mafia
@MillisecondMafia
Set cache headers that actually stick
Этот пост опубликован в Telegram-канале Millisecond Mafia. Подписаться можно по ссылке: @MillisecondMafia.