A conditional get request or cache validation request is a conditional request made by the user agent to see if a stale resource is still valid.
If conditional headers leads to conditional requests. For instance:
If-Modified-Since: Sat, 07 Feb 2015 16:44:03 GMT
If-None-Match: "e026b5aa0e4be8d990f093176b3dcb7f"
Note that you can get one or both from the user agent (browser)
This conditional headers leads to conditional requests:
Headers | Cache Validator | Condition |
---|---|---|
If-Match | ETag | The Etag should be the same |
If-None-Match | ETag | The Etag should not be the same |
If-Modified-Since | Last-Modified date | The date should be more recent |
If-Unmodified-Since | Last-Modified date | The date is older or the same |
If-Range | ETag or Last-Modified date | Similar to If-Match, or If-Unmodified-Since for range request |
The are known in the specification as Precondition Header Fields
The browser (or any other user-agent):
This header are called validator header because they will be send back to the server and will then permit to see if the resource has changed since the last fetch (hence validating the freshness of the cache).
When the resource becomes stale in the cache, the client may send a condition request to see if the resource is still valid. If this is the case and that the resource has not changed, the server sends back a 304 Not Modified response without the body making the request smaller in size.
The cache becomes fresh again, and the client uses the cached resource.