Caching and Asset Invalidation
Build fingerprint strategy
During npm run build, scripts/copyAssets.js now fingerprints distributable CSS/JS/MJS files by
appending a SHA-256 hash fragment to each filename (for example, index.1a2b3c4d5e6f.js). The script also
writes asset-manifest.json files in both dist/ and docs/ so deployments can map logical
asset names to immutable fingerprinted files.
Server cache headers
- Fingerprinted files:
Cache-Control: public, max-age=31536000, immutable. - HTML entry points:
Cache-Control: public, max-age=60, must-revalidate. - Other static assets:
Cache-Control: public, max-age=600, must-revalidate.
This keeps HTML fresh while allowing browsers and CDNs to aggressively cache immutable bundles.
Compression behavior
The server enables gzip compression for text-like responses (HTML, CSS, JS, JSON, XML, SVG) when payload size is at
least 1 KB. Clients can bypass compression for troubleshooting by sending x-no-compression.
Invalidation process
- Run
npm run buildto regenerate bundles and fingerprinted assets. - Deploy both the updated HTML entry points and new fingerprinted files.
- Keep old fingerprinted files available during rollout to avoid transient 404s from in-flight clients.
- After traffic has fully shifted, old fingerprinted files can be pruned safely.