Tutorial by Examples

Cache-Control: public, max-age=31536000 public means the response is the same for all users (it does not contain any personalized information). max-age is in seconds from now. 31536000 = 60 * 60 * 24 * 365. This is recommended for static assets that are never meant to change.
Cache-Control: private, max-age=60 private specifies that the response can be cached only for user who requested the resource, and can't be reused when other users request the same resource. This is appropriate for responses that depend on cookies.
Cache-Control: no-cache The client will behave as if the response was not cached. This is appropriate for resources that can unpredictably change at any time, and which users must always see in the latest version. Responses with no-cache will be slower (high latency) due to need to contact the s...
Cache-control: no-store Instructs clients no to cache the response in any way, and to forget it at soon as possible. This directive was originally designed for sensitive data (today HTTPS should be used instead), but can be used to avoid polluting caches with responses that can't be reused. It...
Expires — specifies date when the resource becomes stale. It relies on servers and clients having accurate clocks and supporting time zones correctly. Cache-control: max-age takes precedence over Expires, and is generally more reliable. post-check and pre-check directives are non-standard I...
The easiest method to bypass cache is to change the URL. This is used as a best practice when the URL contains a version or a checksum of the resource, e.g. http://example.com/image.png?version=1 http://example.com/image.png?version=2 These two URLs will be cached separately, so even if …?versi...

Page 1 of 1