Set cache rules for static pages
Give HTML and versioned assets cache lifetimes that reflect how they change.
Pick a lifetime by resource type
For HTML that may change without changing its URL, use a short lifetime or revalidation. An asset whose URL includes a content hash can use a longer lifetime because changes produce a new URL.
- HTML
Cache-Control: no-cacheallows storage but requires validation before reuse.- Versioned CSS or JavaScript
Cache-Control: public, max-age=31536000, immutablefits assets whose URLs change whenever their content changes.- Private responses
Cache-Control: no-storetells caches to avoid storing sensitive content.
Verify headers from a client
curl -sSI https://example.com/Inspect Cache-Control, ETag, and Age. Run the check against HTML and an asset separately.