Web platform
Understanding HTTP caching
Distinguish freshness, validation and versioned assets.
On this page
Freshness
Cache-Control max-age expresses how long a response can be reused without contacting the server. Choose a duration that matches how frequently the content changes.
Validation
ETag and Last-Modified allow a client to check whether a representation changed. A 304 response avoids sending the response body again.
Versioned assets
Use a content hash in filenames for long-lived CSS and JavaScript. Keep HTML on a shorter freshness policy so it can point to new assets.
Example
Cache-Control: public, max-age=3600
ETag: "example-v2"