Validators & conditional requests
06A validator lets a client ask whether cached content is current or whether an edit would overwrite a newer version.
A stale condition fails instead of silently overwriting revision 8.
Key idea: Attach a precondition before reading or changing state.
Terms
- Client / user agent
- The app making a request; in this example, your browser.
- Origin server
- The server responsible for providing an answer for the target resource.
- Request
- A message asking for an action on a resource.
- Response
- The server’s message reporting the result of a request.
- Resource
- Something identified by a URI, such as the page at /story.
- Representation
- Content and descriptive information that convey a resource’s state, such as an HTML page.
- Semantics
- What a message or protocol element means, independently of how it travels.
- Validator
- Information used to compare representation states.
- ETag
- An opaque tag assigned to a representation; clients compare it rather than interpret its spelling.
- Precondition
- A condition checked before applying a request’s method.
- If-Match
- A condition requiring a strong match with a current representation tag.
- 304 / 412
- 304 reports no need to transfer content for an applicable conditional read; 412 reports a failed precondition.
Rules & examples
Attach a precondition before reading or changing state.
- If-None-Match can revalidate GET or HEAD; an unchanged representation can produce 304.
- If-Match uses strong comparison and can prevent overwriting a changed representation.
- Failed preconditions generally produce 412, with evaluation order defined in §13.2.
Weak validators can establish semantic equivalence for some uses; they do not prove byte-for-byte identity for every operation. A 304 has no response content.
Predict: An edit uses If-Match with an old tag. Does the server silently overwrite a newer version?
Check your answer
When the precondition fails, the method is not applied; the response is normally 412 Precondition Failed.
Sources
New to this? Start hereA quick picture + helpful background
A request starts a conversation.
A client asks for a resource. A server sends a response. The method, address, headers, and status explain what that conversation means.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.