Why this matters
Hashed filenames guarantee cache-busting on deploys and enable safe year-long immutable caching for fast repeat loads.
All static JS/CSS/font/image files MUST use content-hashed filenames (e.g., app.9c1a7b.js) and be served with "Cache-Control: public, max-age=31536000, immutable". HTML and other non-fingerprinted documents MUST be served with "Cache-Control: no-cache" (or equivalent) to enable conditional revalidation.
Hashed filenames guarantee cache-busting on deploys and enable safe year-long immutable caching for fast repeat loads.
Side-by-side examples engineers can pattern-match during review.
GET /assets/app.js
200 OK
Cache-Control: max-age=600
/* filename without hash; short-lived cache /GET /assets/app.9c1a7b.js
200 OK
Cache-Control: public, max-age=31536000, immutable
/ hashed filename; immutable caching /Cache-Control: public, max-age=31536000, immutableCache-Control: max-age=600From the same buckets as this rule.
Serve text-based assets (JS, CSS, JSON, SVG) with Brotli (br) when the client sends "Accept-Encoding: br" and fallback to gzip. Always set "Vary: Accept-Encoding" and do NOT compress already-compressed formats (e.g., .png, .jpg, .woff2).
In Express, use serve-static with setHeaders to apply "Cache-Control: public, max-age=31536000, immutable" for files matching /\.[0-9a-f]{8,}\./ and "Cache-Control: no-cache" for HTML. Also set correct Content-Type.