Expires
HTTP header contains the date/time after which the response is considered expired.Cache-Control
max-age=<seconds>
response directive indicates that the response remains fresh until N seconds after the response is generated.no-cache
response directive indicates that the response can be stored in caches, but the response must be validated with the origin server before each reuse, even when the cache is disconnected from the origin server.no-store
response directive indicates that any caches of any kind (private or shared) should not store this response.Last-Modified
response HTTP header contains a date and time when the origin server believes the resource was last modified. Less accurate than an ETag
header, it is a fallback mechanism.If-Modified-Since
request HTTP header makes the request conditional: the server sends back the requested resource, with a 200
status, only if it has been last modified after the given date. If the resource has not been modified since, the response is a 304
without any body; the Last-Modified
response header of a previous request contains the date of last modification.ETag
(or entity tag) HTTP response header is an identifier for a specific version of a resource.If-None-Match
HTTP request header makes the request conditional. For GET
and HEAD
methods, the server will return the requested resource, with a 200
status, only if it doesn't have an ETag
matching the given ones.HTTP is designed to cache as much as possible, so even if no Cache-Control
is given, responses will get stored and reused if certain conditions are met. This is called heuristic caching.
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1024
Date: Tue, 22 Feb 2022 22:22:22 GMT
Last-Modified: Tue, 22 Feb 2021 22:22:22 GMT
<!doctype html>
…
It is heuristically known that content which has not been updated for a full year will not be updated for some time after that. Therefore, the client stores this response (despite the lack of max-age
) and reuses it for a while. How long to reuse is up to the implementation, but the specification recommends about 10% (in this case 0.1 year) of the time after storing.
(`Date` - `Last-Modified`) / 10