304 Not Modified
syndicated from planet-php.net
on October 9, 2018
304 Not Modified is used in response to a conditional GET or HEAD
request. A request can be made condtional with one of the following headers:
If-MatchIf-None-MatchIf-Modified-SinceIf-Unmodified-SinceIf-Range
If-Modified-Since and If-None-Match are used specifically to allow a
client to cache results and asks the server to only send a new representation
if it has changed.
If-Modified-Since does this based on a Last-Modified header, and
If-None-Match with an ETag.
Example
A client does an initial request:
GET /foo HTTP/1.1
Accept: text/html
A server responds with an ETag:
HTTP/1.1 200 Ok
Content-Type: text/html
ETag: "some-string"
The next time a client makes a request, it can include the ETag:
GET /foo HTTP/1.1
Accept: text/html
If-None-Match: "some-string"
If the resource didn’t change on the server, it can return a 304.
HTTP/1.1 304 Not Modified
ETag: "some-string"
References
- RFC7232, Section 4.1 - 304 Not Modified