Cache Control

HTTP Dev

Aggressive Caching

1
Cache-Control: public, max-age=604800, immutable

Aggressive Cache Prevention

1
Cache-Control: no-store, max-age=0

Directives no-cache vs no-store

There is a lot of confusion around no-cache and no-store. The no-cache directive allows the response to be stored in any cache. However the stored response must always go through validation with the origin server first.

Cache Validation

When cached content expires or revaliation is required because cache-control directives require it, the cache will forward a content request with an If-None-Match header to check if the content is fresh.

1
2
3
If-None-Match: "<etag_value>"
If-None-Match: "<etag_value>", "<etag_value>", …
If-None-Match: *

The asterisk means any resource and is only useful when uploading a resource to check if another resource with the identity has been uplaoded before.

Using this header makes the GET or HEAD request optional. These methods will return a 304 (Not Modified) response if the ETag matches.