Performance

perf/cache-static-assets

Content-hashed assets are cached for a year as immutable; HTML is revalidated (no-cache), never cached long.

moderatebrowserfe-perf-delivery

Why

Without long cache lifetimes, returning visitors download the same scripts, styles, fonts and images again. With long lifetimes on HTML or on files whose names do not change, visitors keep seeing an old version after a deploy.

Fix

Let the build add a content hash to file names (Vite, webpack and the frameworks do it by default) and serve those with Cache-Control: public, max-age=31536000, immutable. Serve HTML with Cache-Control: no-cache so it is revalidated each time. Configure it in the host's headers file (_headers, vercel.json, netlify.toml, server config).

Examples

# _headers (Netlify, Cloudflare Pages)
/assets/*
  Cache-Control: public, max-age=31536000, immutable
/*.html
  Cache-Control: no-cache

Sources

Facts

Id
perf/cache-static-assets
Severity
moderate
Check
browser needs a rendered page: audit --url
Applies to
page
Same problem in
Lighthouse cache-insight
Taught by the skill
fe-perf-delivery JavaScript, CSS and asset delivery
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain perf/cache-static-assets