6. Precedence
When more than one conditional request header field is present in a request, the order in which the fields are evaluated becomes important. In practice, the fields defined in this document are consistently implemented in a single, logical order, since "lost update" preconditions have more strict requirements than cache validation, and an entity-tag is presumed to be more accurate than a date value.
A recipient cache or origin server MUST evaluate the request preconditions defined by this specification in the following order:
-
When recipient is the origin server and
If-Matchis present, evaluate theIf-Matchprecondition:- if true, continue to step 3
- if false, respond 412 (Precondition Failed) unless it can be determined that the state-changing request has already succeeded (see Section 3.1)
-
When recipient is the origin server,
If-Matchis not present, andIf-Unmodified-Sinceis present, evaluate theIf-Unmodified-Sinceprecondition:- if true, continue to step 3
- if false, respond 412 (Precondition Failed) unless it can be determined that the state-changing request has already succeeded (see Section 3.4)
-
When
If-None-Matchis present, evaluate theIf-None-Matchprecondition:- if true, continue to step 5
- if false for GET/HEAD, respond 304 (Not Modified)
- if false for other methods, respond 412 (Precondition Failed)
-
When the method is GET or HEAD,
If-None-Matchis not present, andIf-Modified-Sinceis present, evaluate theIf-Modified-Sinceprecondition:- if true, continue to step 5
- if false, respond 304 (Not Modified)
-
When the method is GET and both
RangeandIf-Rangeare present, evaluate theIf-Rangeprecondition:- if true and the Range specification is applicable to the selected representation, respond 206 (Partial Content) [RFC7233]
- otherwise, ignore the Range header field and respond 200 (OK)
-
Otherwise,
- perform the requested method and respond according to its success or failure.
Any extension to HTTP that defines additional conditional request header fields ought to define its own order of evaluation relative to the conditional request header fields defined in this document. Allowing extension fields to redefine the precedence of standard conditional header fields, or to depend on a standard field's evaluation outcome, would lead to ambiguous or inconsistent behavior.