/ THE IDEA
HTTP is the set of request-and-response rules used for ordinary web communication. A resource is an item identified by a web address. A representation is the particular content form being returned, such as an English-language document. A server can attach an entity tag, usually written ETag, to that representation. The tag is an identifier the server chooses for comparison. Later, the browser sends a GET request, meaning retrieve this resource, with If-None-Match containing its stored tag. If the selected representation matches, the server returns status 304, Not Modified, rather than a replacement content body. If it does not match, a normal successful response can carry the new content and a new tag.
THE FORMAL IDEA
GET + If-None-Match: "v7" → compare current ETag
| The quoted v7 is a toy opaque identifier: clients must not assume it is a version number they can increment. | | GET, If-None-Match and 304 are HTTP names. A response body is the actual document content, separate from the response’s descriptive headers. |
|
RUN THE TINY EXAMPLE
Change one thing. Predict what happens.
Browser holds a 200 kB document with ETag "v7"; the server still selects "v7". Conditional GET receives 304, so no replacement 200 kB body is transferred. Change one input: the server selects a changed document tagged "v8". The tags differ, so the server returns the new body with its new ETag instead.
|
The first answer validates reuse; it does not mean the server returned an empty document for the browser to display. The browser still needs the stored body. In the second answer, the extra bytes are useful because the old copy no longer matches.
/ SO WHAT?
A successful validation still requires communication. It saves content transfer, not every network wait. When examining browser traffic, a 304 response can therefore be evidence of a functioning version check rather than a broken download. It also explains why repeatedly checking an unchanged large document may use little body traffic while still creating requests for the server to evaluate.
ONE CAVEAT |
| Entity tags can be weak or strong and are not necessarily cryptographic hashes. Representation selection and correct server tagging matter; a conditional request is only as meaningful as the comparison being maintained. |
KEEP THIS
A version comparison can replace a full download when the server confirms that the body already held is still suitable.
|
NEXT: Why adding water raises the note of a blown bottle
|