HTTP cheatsheet
HTTP: Caching
6 common HTTP tasks.
Cache static files for a year
Safe for files whose names change with their content, such as app.3f9a1c.js.
Cache-Control: public, max-age=31536000, immutable
Always check with the server
The cache may keep a copy but must revalidate it before each use.
Cache-Control: no-cache
ETag: a version label
A fingerprint of the response. Clients send it back to ask whether the resource changed.
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
If-None-Match: a conditional request
Send the ETag you have. The server answers 304 with no body if it is unchanged.
If-None-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"
Vary: cache by request header
Says which request headers change the response, so caches store separate copies.
Vary: Accept-Encoding