idnits 2.17.1
draft-ietf-httpbis-conditional-00.txt:
Checking boilerplate required by RFC 5378 and the IETF Trust (see
https://trustee.ietf.org/license-info):
----------------------------------------------------------------------------
No issues found here.
Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt:
----------------------------------------------------------------------------
No issues found here.
Checking nits according to https://www.ietf.org/id-info/checklist :
----------------------------------------------------------------------------
No issues found here.
Miscellaneous warnings:
----------------------------------------------------------------------------
== The copyright year in the IETF Trust and authors Copyright Line does not
match the current year
== The document seems to contain a disclaimer for pre-RFC5378 work, but was
first submitted on or after 10 November 2008. The disclaimer is usually
necessary only for documents that revise or obsolete older RFCs, and that
take significant amounts of text from those RFCs. If you can contact all
authors of the source material and they are willing to grant the BCP78
rights to the IETF Trust, you can and should remove the disclaimer.
Otherwise, the disclaimer is needed and you can ignore this comment.
(See the Legal Provisions document at
https://trustee.ietf.org/license-info for more information.)
-- The document date (April 3, 2018) is 2214 days in the past. Is this
intentional?
Checking references for intended status: Proposed Standard
----------------------------------------------------------------------------
(See RFCs 3967 and 4897 for information about using normative references
to lower-maturity documents in RFCs)
== Unused Reference: 'RFC7232' is defined on line 1065, but no explicit
reference was found in the text
== Outdated reference: A later version (-19) exists of
draft-ietf-httpbis-cache-00
-- Possible downref: Normative reference to a draft: ref. 'CACHING'
== Outdated reference: A later version (-19) exists of
draft-ietf-httpbis-messaging-00
-- Possible downref: Normative reference to a draft: ref. 'MESSGNG'
== Outdated reference: A later version (-01) exists of
draft-ietf-httpbis-range-00
== Outdated reference: A later version (-19) exists of
draft-ietf-httpbis-semantics-00
-- Possible downref: Normative reference to a draft: ref. 'SEMNTCS'
-- Obsolete informational reference (is this intentional?): RFC 2616
(Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235)
-- Obsolete informational reference (is this intentional?): RFC 7232
(Obsoleted by RFC 9110)
Summary: 0 errors (**), 0 flaws (~~), 7 warnings (==), 6 comments (--).
Run idnits with the --verbose option for more detailed information about
the items above.
--------------------------------------------------------------------------------
2 HTTP Working Group R. Fielding, Ed.
3 Internet-Draft Adobe
4 Obsoletes: 7232 (if approved) M. Nottingham, Ed.
5 Intended status: Standards Track Fastly
6 Expires: October 5, 2018 J. Reschke, Ed.
7 greenbytes
8 April 3, 2018
10 Hypertext Transfer Protocol (HTTP): Conditional Requests
11 draft-ietf-httpbis-conditional-00
13 Abstract
15 The Hypertext Transfer Protocol (HTTP) is a stateless application-
16 level protocol for distributed, collaborative, hypertext information
17 systems. This document defines HTTP/1.1 conditional requests,
18 including metadata header fields for indicating state changes,
19 request header fields for making preconditions on such state, and
20 rules for constructing the responses to a conditional request when
21 one or more preconditions evaluate to false.
23 This document obsoletes RFC 7232.
25 Editorial Note
27 This note is to be removed before publishing as an RFC.
29 Discussion of this draft takes place on the HTTP working group
30 mailing list (ietf-http-wg@w3.org), which is archived at
31 .
33 Working Group information can be found at ;
34 source code and issues list for this draft can be found at
35 .
37 The changes in this draft are summarized in Appendix D.1.
39 Status of This Memo
41 This Internet-Draft is submitted in full conformance with the
42 provisions of BCP 78 and BCP 79.
44 Internet-Drafts are working documents of the Internet Engineering
45 Task Force (IETF). Note that other groups may also distribute
46 working documents as Internet-Drafts. The list of current Internet-
47 Drafts is at https://datatracker.ietf.org/drafts/current/.
49 Internet-Drafts are draft documents valid for a maximum of six months
50 and may be updated, replaced, or obsoleted by other documents at any
51 time. It is inappropriate to use Internet-Drafts as reference
52 material or to cite them other than as "work in progress."
54 This Internet-Draft will expire on October 5, 2018.
56 Copyright Notice
58 Copyright (c) 2018 IETF Trust and the persons identified as the
59 document authors. All rights reserved.
61 This document is subject to BCP 78 and the IETF Trust's Legal
62 Provisions Relating to IETF Documents
63 (https://trustee.ietf.org/license-info) in effect on the date of
64 publication of this document. Please review these documents
65 carefully, as they describe your rights and restrictions with respect
66 to this document. Code Components extracted from this document must
67 include Simplified BSD License text as described in Section 4.e of
68 the Trust Legal Provisions and are provided without warranty as
69 described in the Simplified BSD License.
71 This document may contain material from IETF Documents or IETF
72 Contributions published or made publicly available before November
73 10, 2008. The person(s) controlling the copyright in some of this
74 material may not have granted the IETF Trust the right to allow
75 modifications of such material outside the IETF Standards Process.
76 Without obtaining an adequate license from the person(s) controlling
77 the copyright in such materials, this document may not be modified
78 outside the IETF Standards Process, and derivative works of it may
79 not be created outside the IETF Standards Process, except to format
80 it for publication as an RFC or to translate it into languages other
81 than English.
83 Table of Contents
85 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
86 1.1. Conformance and Error Handling . . . . . . . . . . . . . 4
87 1.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 4
88 2. Validators . . . . . . . . . . . . . . . . . . . . . . . . . 4
89 2.1. Weak versus Strong . . . . . . . . . . . . . . . . . . . 5
90 2.2. Last-Modified . . . . . . . . . . . . . . . . . . . . . . 6
91 2.2.1. Generation . . . . . . . . . . . . . . . . . . . . . 7
92 2.2.2. Comparison . . . . . . . . . . . . . . . . . . . . . 7
93 2.3. ETag . . . . . . . . . . . . . . . . . . . . . . . . . . 8
94 2.3.1. Generation . . . . . . . . . . . . . . . . . . . . . 9
95 2.3.2. Comparison . . . . . . . . . . . . . . . . . . . . . 10
96 2.3.3. Example: Entity-Tags Varying on Content-Negotiated
97 Resources . . . . . . . . . . . . . . . . . . . . . . 10
98 2.4. When to Use Entity-Tags and Last-Modified Dates . . . . . 11
99 3. Precondition Header Fields . . . . . . . . . . . . . . . . . 12
100 3.1. If-Match . . . . . . . . . . . . . . . . . . . . . . . . 12
101 3.2. If-None-Match . . . . . . . . . . . . . . . . . . . . . . 13
102 3.3. If-Modified-Since . . . . . . . . . . . . . . . . . . . . 15
103 3.4. If-Unmodified-Since . . . . . . . . . . . . . . . . . . . 16
104 3.5. If-Range . . . . . . . . . . . . . . . . . . . . . . . . 17
105 4. Status Code Definitions . . . . . . . . . . . . . . . . . . . 17
106 4.1. 304 Not Modified . . . . . . . . . . . . . . . . . . . . 17
107 4.2. 412 Precondition Failed . . . . . . . . . . . . . . . . . 18
108 5. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . 18
109 6. Precedence . . . . . . . . . . . . . . . . . . . . . . . . . 19
110 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 20
111 7.1. Status Code Registration . . . . . . . . . . . . . . . . 20
112 7.2. Header Field Registration . . . . . . . . . . . . . . . . 21
113 8. Security Considerations . . . . . . . . . . . . . . . . . . . 21
114 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 22
115 9.1. Normative References . . . . . . . . . . . . . . . . . . 22
116 9.2. Informative References . . . . . . . . . . . . . . . . . 23
117 Appendix A. Changes from RFC 7232 . . . . . . . . . . . . . . . 24
118 Appendix B. Imported ABNF . . . . . . . . . . . . . . . . . . . 24
119 Appendix C. Collected ABNF . . . . . . . . . . . . . . . . . . . 24
120 Appendix D. Change Log . . . . . . . . . . . . . . . . . . . . . 25
121 D.1. Since RFC 7232 . . . . . . . . . . . . . . . . . . . . . 25
122 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
123 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 27
124 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 27
126 1. Introduction
128 Conditional requests are HTTP requests [SEMNTCS] that include one or
129 more header fields indicating a precondition to be tested before
130 applying the method semantics to the target resource. This document
131 defines the HTTP/1.1 conditional request mechanisms in terms of the
132 architecture, syntax notation, and conformance criteria defined in
133 [MESSGNG].
135 Conditional GET requests are the most efficient mechanism for HTTP
136 cache updates [CACHING]. Conditionals can also be applied to state-
137 changing methods, such as PUT and DELETE, to prevent the "lost
138 update" problem: one client accidentally overwriting the work of
139 another client that has been acting in parallel.
141 Conditional request preconditions are based on the state of the
142 target resource as a whole (its current value set) or the state as
143 observed in a previously obtained representation (one value in that
144 set). A resource might have multiple current representations, each
145 with its own observable state. The conditional request mechanisms
146 assume that the mapping of requests to a "selected representation"
147 (Section 3 of [SEMNTCS]) will be consistent over time if the server
148 intends to take advantage of conditionals. Regardless, if the
149 mapping is inconsistent and the server is unable to select the
150 appropriate representation, then no harm will result when the
151 precondition evaluates to false.
153 The conditional request preconditions defined by this specification
154 (Section 3) are evaluated when applicable to the recipient
155 (Section 5) according to their order of precedence (Section 6).
157 This specification obsoletes RFC 7232, with the changes being
158 summarized in Appendix A.
160 1.1. Conformance and Error Handling
162 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
163 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
164 document are to be interpreted as described in [RFC2119].
166 Conformance criteria and considerations regarding error handling are
167 defined in Section 2.5 of [MESSGNG].
169 1.2. Syntax Notation
171 This specification uses the Augmented Backus-Naur Form (ABNF)
172 notation of [RFC5234] with a list extension, defined in Section 7 of
173 [MESSGNG], that allows for compact definition of comma-separated
174 lists using a '#' operator (similar to how the '*' operator indicates
175 repetition). Appendix B describes rules imported from other
176 documents. Appendix C shows the collected grammar with all list
177 operators expanded to standard ABNF notation.
179 2. Validators
181 This specification defines two forms of metadata that are commonly
182 used to observe resource state and test for preconditions:
183 modification dates (Section 2.2) and opaque entity tags
184 (Section 2.3). Additional metadata that reflects resource state has
185 been defined by various extensions of HTTP, such as Web Distributed
186 Authoring and Versioning (WebDAV, [RFC4918]), that are beyond the
187 scope of this specification. A resource metadata value is referred
188 to as a "validator" when it is used within a precondition.
190 2.1. Weak versus Strong
192 Validators come in two flavors: strong or weak. Weak validators are
193 easy to generate but are far less useful for comparisons. Strong
194 validators are ideal for comparisons but can be very difficult (and
195 occasionally impossible) to generate efficiently. Rather than impose
196 that all forms of resource adhere to the same strength of validator,
197 HTTP exposes the type of validator in use and imposes restrictions on
198 when weak validators can be used as preconditions.
200 A "strong validator" is representation metadata that changes value
201 whenever a change occurs to the representation data that would be
202 observable in the payload body of a 200 (OK) response to GET.
204 A strong validator might change for reasons other than a change to
205 the representation data, such as when a semantically significant part
206 of the representation metadata is changed (e.g., Content-Type), but
207 it is in the best interests of the origin server to only change the
208 value when it is necessary to invalidate the stored responses held by
209 remote caches and authoring tools.
211 Cache entries might persist for arbitrarily long periods, regardless
212 of expiration times. Thus, a cache might attempt to validate an
213 entry using a validator that it obtained in the distant past. A
214 strong validator is unique across all versions of all representations
215 associated with a particular resource over time. However, there is
216 no implication of uniqueness across representations of different
217 resources (i.e., the same strong validator might be in use for
218 representations of multiple resources at the same time and does not
219 imply that those representations are equivalent).
221 There are a variety of strong validators used in practice. The best
222 are based on strict revision control, wherein each change to a
223 representation always results in a unique node name and revision
224 identifier being assigned before the representation is made
225 accessible to GET. A collision-resistant hash function applied to
226 the representation data is also sufficient if the data is available
227 prior to the response header fields being sent and the digest does
228 not need to be recalculated every time a validation request is
229 received. However, if a resource has distinct representations that
230 differ only in their metadata, such as might occur with content
231 negotiation over media types that happen to share the same data
232 format, then the origin server needs to incorporate additional
233 information in the validator to distinguish those representations.
235 In contrast, a "weak validator" is representation metadata that might
236 not change for every change to the representation data. This
237 weakness might be due to limitations in how the value is calculated,
238 such as clock resolution, an inability to ensure uniqueness for all
239 possible representations of the resource, or a desire of the resource
240 owner to group representations by some self-determined set of
241 equivalency rather than unique sequences of data. An origin server
242 SHOULD change a weak entity-tag whenever it considers prior
243 representations to be unacceptable as a substitute for the current
244 representation. In other words, a weak entity-tag ought to change
245 whenever the origin server wants caches to invalidate old responses.
247 For example, the representation of a weather report that changes in
248 content every second, based on dynamic measurements, might be grouped
249 into sets of equivalent representations (from the origin server's
250 perspective) with the same weak validator in order to allow cached
251 representations to be valid for a reasonable period of time (perhaps
252 adjusted dynamically based on server load or weather quality).
253 Likewise, a representation's modification time, if defined with only
254 one-second resolution, might be a weak validator if it is possible
255 for the representation to be modified twice during a single second
256 and retrieved between those modifications.
258 Likewise, a validator is weak if it is shared by two or more
259 representations of a given resource at the same time, unless those
260 representations have identical representation data. For example, if
261 the origin server sends the same validator for a representation with
262 a gzip content coding applied as it does for a representation with no
263 content coding, then that validator is weak. However, two
264 simultaneous representations might share the same strong validator if
265 they differ only in the representation metadata, such as when two
266 different media types are available for the same representation data.
268 Strong validators are usable for all conditional requests, including
269 cache validation, partial content ranges, and "lost update"
270 avoidance. Weak validators are only usable when the client does not
271 require exact equality with previously obtained representation data,
272 such as when validating a cache entry or limiting a web traversal to
273 recent changes.
275 2.2. Last-Modified
277 The "Last-Modified" header field in a response provides a timestamp
278 indicating the date and time at which the origin server believes the
279 selected representation was last modified, as determined at the
280 conclusion of handling the request.
282 Last-Modified = HTTP-date
284 An example of its use is
285 Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
287 2.2.1. Generation
289 An origin server SHOULD send Last-Modified for any selected
290 representation for which a last modification date can be reasonably
291 and consistently determined, since its use in conditional requests
292 and evaluating cache freshness ([CACHING]) results in a substantial
293 reduction of HTTP traffic on the Internet and can be a significant
294 factor in improving service scalability and reliability.
296 A representation is typically the sum of many parts behind the
297 resource interface. The last-modified time would usually be the most
298 recent time that any of those parts were changed. How that value is
299 determined for any given resource is an implementation detail beyond
300 the scope of this specification. What matters to HTTP is how
301 recipients of the Last-Modified header field can use its value to
302 make conditional requests and test the validity of locally cached
303 responses.
305 An origin server SHOULD obtain the Last-Modified value of the
306 representation as close as possible to the time that it generates the
307 Date field value for its response. This allows a recipient to make
308 an accurate assessment of the representation's modification time,
309 especially if the representation changes near the time that the
310 response is generated.
312 An origin server with a clock MUST NOT send a Last-Modified date that
313 is later than the server's time of message origination (Date). If
314 the last modification time is derived from implementation-specific
315 metadata that evaluates to some time in the future, according to the
316 origin server's clock, then the origin server MUST replace that value
317 with the message origination date. This prevents a future
318 modification date from having an adverse impact on cache validation.
320 An origin server without a clock MUST NOT assign Last-Modified values
321 to a response unless these values were associated with the resource
322 by some other system or user with a reliable clock.
324 2.2.2. Comparison
326 A Last-Modified time, when used as a validator in a request, is
327 implicitly weak unless it is possible to deduce that it is strong,
328 using the following rules:
330 o The validator is being compared by an origin server to the actual
331 current validator for the representation and,
333 o That origin server reliably knows that the associated
334 representation did not change twice during the second covered by
335 the presented validator.
337 or
339 o The validator is about to be used by a client in an If-Modified-
340 Since, If-Unmodified-Since, or If-Range header field, because the
341 client has a cache entry for the associated representation, and
343 o That cache entry includes a Date value, which gives the time when
344 the origin server sent the original response, and
346 o The presented Last-Modified time is at least 60 seconds before the
347 Date value.
349 or
351 o The validator is being compared by an intermediate cache to the
352 validator stored in its cache entry for the representation, and
354 o That cache entry includes a Date value, which gives the time when
355 the origin server sent the original response, and
357 o The presented Last-Modified time is at least 60 seconds before the
358 Date value.
360 This method relies on the fact that if two different responses were
361 sent by the origin server during the same second, but both had the
362 same Last-Modified time, then at least one of those responses would
363 have a Date value equal to its Last-Modified time. The arbitrary
364 60-second limit guards against the possibility that the Date and
365 Last-Modified values are generated from different clocks or at
366 somewhat different times during the preparation of the response. An
367 implementation MAY use a value larger than 60 seconds, if it is
368 believed that 60 seconds is too short.
370 2.3. ETag
372 The "ETag" header field in a response provides the current entity-tag
373 for the selected representation, as determined at the conclusion of
374 handling the request. An entity-tag is an opaque validator for
375 differentiating between multiple representations of the same
376 resource, regardless of whether those multiple representations are
377 due to resource state changes over time, content negotiation
378 resulting in multiple representations being valid at the same time,
379 or both. An entity-tag consists of an opaque quoted string, possibly
380 prefixed by a weakness indicator.
382 ETag = entity-tag
384 entity-tag = [ weak ] opaque-tag
385 weak = %x57.2F ; "W/", case-sensitive
386 opaque-tag = DQUOTE *etagc DQUOTE
387 etagc = %x21 / %x23-7E / obs-text
388 ; VCHAR except double quotes, plus obs-text
390 Note: Previously, opaque-tag was defined to be a quoted-string
391 ([RFC2616], Section 3.11); thus, some recipients might perform
392 backslash unescaping. Servers therefore ought to avoid backslash
393 characters in entity tags.
395 An entity-tag can be more reliable for validation than a modification
396 date in situations where it is inconvenient to store modification
397 dates, where the one-second resolution of HTTP date values is not
398 sufficient, or where modification dates are not consistently
399 maintained.
401 Examples:
403 ETag: "xyzzy"
404 ETag: W/"xyzzy"
405 ETag: ""
407 An entity-tag can be either a weak or strong validator, with strong
408 being the default. If an origin server provides an entity-tag for a
409 representation and the generation of that entity-tag does not satisfy
410 all of the characteristics of a strong validator (Section 2.1), then
411 the origin server MUST mark the entity-tag as weak by prefixing its
412 opaque value with "W/" (case-sensitive).
414 2.3.1. Generation
416 The principle behind entity-tags is that only the service author
417 knows the implementation of a resource well enough to select the most
418 accurate and efficient validation mechanism for that resource, and
419 that any such mechanism can be mapped to a simple sequence of octets
420 for easy comparison. Since the value is opaque, there is no need for
421 the client to be aware of how each entity-tag is constructed.
423 For example, a resource that has implementation-specific versioning
424 applied to all changes might use an internal revision number, perhaps
425 combined with a variance identifier for content negotiation, to
426 accurately differentiate between representations. Other
427 implementations might use a collision-resistant hash of
428 representation content, a combination of various file attributes, or
429 a modification timestamp that has sub-second resolution.
431 An origin server SHOULD send an ETag for any selected representation
432 for which detection of changes can be reasonably and consistently
433 determined, since the entity-tag's use in conditional requests and
434 evaluating cache freshness ([CACHING]) can result in a substantial
435 reduction of HTTP network traffic and can be a significant factor in
436 improving service scalability and reliability.
438 2.3.2. Comparison
440 There are two entity-tag comparison functions, depending on whether
441 or not the comparison context allows the use of weak validators:
443 o Strong comparison: two entity-tags are equivalent if both are not
444 weak and their opaque-tags match character-by-character.
446 o Weak comparison: two entity-tags are equivalent if their opaque-
447 tags match character-by-character, regardless of either or both
448 being tagged as "weak".
450 The example below shows the results for a set of entity-tag pairs and
451 both the weak and strong comparison function results:
453 +--------+--------+-------------------+-----------------+
454 | ETag 1 | ETag 2 | Strong Comparison | Weak Comparison |
455 +--------+--------+-------------------+-----------------+
456 | W/"1" | W/"1" | no match | match |
457 | W/"1" | W/"2" | no match | no match |
458 | W/"1" | "1" | no match | match |
459 | "1" | "1" | match | match |
460 +--------+--------+-------------------+-----------------+
462 2.3.3. Example: Entity-Tags Varying on Content-Negotiated Resources
464 Consider a resource that is subject to content negotiation
465 (Section 3.4 of [SEMNTCS]), and where the representations sent in
466 response to a GET request vary based on the Accept-Encoding request
467 header field (Section 5.3.4 of [SEMNTCS]):
469 >> Request:
471 GET /index HTTP/1.1
472 Host: www.example.com
473 Accept-Encoding: gzip
475 In this case, the response might or might not use the gzip content
476 coding. If it does not, the response might look like:
478 >> Response:
480 HTTP/1.1 200 OK
481 Date: Fri, 26 Mar 2010 00:05:00 GMT
482 ETag: "123-a"
483 Content-Length: 70
484 Vary: Accept-Encoding
485 Content-Type: text/plain
487 Hello World!
488 Hello World!
489 Hello World!
490 Hello World!
491 Hello World!
493 An alternative representation that does use gzip content coding would
494 be:
496 >> Response:
498 HTTP/1.1 200 OK
499 Date: Fri, 26 Mar 2010 00:05:00 GMT
500 ETag: "123-b"
501 Content-Length: 43
502 Vary: Accept-Encoding
503 Content-Type: text/plain
504 Content-Encoding: gzip
506 ...binary data...
508 Note: Content codings are a property of the representation data,
509 so a strong entity-tag for a content-encoded representation has to
510 be distinct from the entity tag of an unencoded representation to
511 prevent potential conflicts during cache updates and range
512 requests. In contrast, transfer codings (Section 4 of [MESSGNG])
513 apply only during message transfer and do not result in distinct
514 entity-tags.
516 2.4. When to Use Entity-Tags and Last-Modified Dates
518 In 200 (OK) responses to GET or HEAD, an origin server:
520 o SHOULD send an entity-tag validator unless it is not feasible to
521 generate one.
523 o MAY send a weak entity-tag instead of a strong entity-tag, if
524 performance considerations support the use of weak entity-tags, or
525 if it is unfeasible to send a strong entity-tag.
527 o SHOULD send a Last-Modified value if it is feasible to send one.
529 In other words, the preferred behavior for an origin server is to
530 send both a strong entity-tag and a Last-Modified value in successful
531 responses to a retrieval request.
533 A client:
535 o MUST send that entity-tag in any cache validation request (using
536 If-Match or If-None-Match) if an entity-tag has been provided by
537 the origin server.
539 o SHOULD send the Last-Modified value in non-subrange cache
540 validation requests (using If-Modified-Since) if only a Last-
541 Modified value has been provided by the origin server.
543 o MAY send the Last-Modified value in subrange cache validation
544 requests (using If-Unmodified-Since) if only a Last-Modified value
545 has been provided by an HTTP/1.0 origin server. The user agent
546 SHOULD provide a way to disable this, in case of difficulty.
548 o SHOULD send both validators in cache validation requests if both
549 an entity-tag and a Last-Modified value have been provided by the
550 origin server. This allows both HTTP/1.0 and HTTP/1.1 caches to
551 respond appropriately.
553 3. Precondition Header Fields
555 This section defines the syntax and semantics of HTTP/1.1 header
556 fields for applying preconditions on requests. Section 5 defines
557 when the preconditions are applied. Section 6 defines the order of
558 evaluation when more than one precondition is present.
560 3.1. If-Match
562 The "If-Match" header field makes the request method conditional on
563 the recipient origin server either having at least one current
564 representation of the target resource, when the field-value is "*",
565 or having a current representation of the target resource that has an
566 entity-tag matching a member of the list of entity-tags provided in
567 the field-value.
569 An origin server MUST use the strong comparison function when
570 comparing entity-tags for If-Match (Section 2.3.2), since the client
571 intends this precondition to prevent the method from being applied if
572 there have been any changes to the representation data.
574 If-Match = "*" / 1#entity-tag
576 Examples:
578 If-Match: "xyzzy"
579 If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
580 If-Match: *
582 If-Match is most often used with state-changing methods (e.g., POST,
583 PUT, DELETE) to prevent accidental overwrites when multiple user
584 agents might be acting in parallel on the same resource (i.e., to
585 prevent the "lost update" problem). It can also be used with safe
586 methods to abort a request if the selected representation does not
587 match one already stored (or partially stored) from a prior request.
589 An origin server that receives an If-Match header field MUST evaluate
590 the condition prior to performing the method (Section 5). If the
591 field-value is "*", the condition is false if the origin server does
592 not have a current representation for the target resource. If the
593 field-value is a list of entity-tags, the condition is false if none
594 of the listed tags match the entity-tag of the selected
595 representation.
597 An origin server MUST NOT perform the requested method if a received
598 If-Match condition evaluates to false; instead, the origin server
599 MUST respond with either a) the 412 (Precondition Failed) status code
600 or b) one of the 2xx (Successful) status codes if the origin server
601 has verified that a state change is being requested and the final
602 state is already reflected in the current state of the target
603 resource (i.e., the change requested by the user agent has already
604 succeeded, but the user agent might not be aware of it, perhaps
605 because the prior response was lost or a compatible change was made
606 by some other user agent). In the latter case, the origin server
607 MUST NOT send a validator header field in the response unless it can
608 verify that the request is a duplicate of an immediately prior change
609 made by the same user agent.
611 The If-Match header field can be ignored by caches and intermediaries
612 because it is not applicable to a stored response.
614 3.2. If-None-Match
616 The "If-None-Match" header field makes the request method conditional
617 on a recipient cache or origin server either not having any current
618 representation of the target resource, when the field-value is "*",
619 or having a selected representation with an entity-tag that does not
620 match any of those listed in the field-value.
622 A recipient MUST use the weak comparison function when comparing
623 entity-tags for If-None-Match (Section 2.3.2), since weak entity-tags
624 can be used for cache validation even if there have been changes to
625 the representation data.
627 If-None-Match = "*" / 1#entity-tag
629 Examples:
631 If-None-Match: "xyzzy"
632 If-None-Match: W/"xyzzy"
633 If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
634 If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"
635 If-None-Match: *
637 If-None-Match is primarily used in conditional GET requests to enable
638 efficient updates of cached information with a minimum amount of
639 transaction overhead. When a client desires to update one or more
640 stored responses that have entity-tags, the client SHOULD generate an
641 If-None-Match header field containing a list of those entity-tags
642 when making a GET request; this allows recipient servers to send a
643 304 (Not Modified) response to indicate when one of those stored
644 responses matches the selected representation.
646 If-None-Match can also be used with a value of "*" to prevent an
647 unsafe request method (e.g., PUT) from inadvertently modifying an
648 existing representation of the target resource when the client
649 believes that the resource does not have a current representation
650 (Section 4.2.1 of [SEMNTCS]). This is a variation on the "lost
651 update" problem that might arise if more than one client attempts to
652 create an initial representation for the target resource.
654 An origin server that receives an If-None-Match header field MUST
655 evaluate the condition prior to performing the method (Section 5).
656 If the field-value is "*", the condition is false if the origin
657 server has a current representation for the target resource. If the
658 field-value is a list of entity-tags, the condition is false if one
659 of the listed tags match the entity-tag of the selected
660 representation.
662 An origin server MUST NOT perform the requested method if the
663 condition evaluates to false; instead, the origin server MUST respond
664 with either a) the 304 (Not Modified) status code if the request
665 method is GET or HEAD or b) the 412 (Precondition Failed) status code
666 for all other request methods.
668 Requirements on cache handling of a received If-None-Match header
669 field are defined in Section 4.3.2 of [CACHING].
671 3.3. If-Modified-Since
673 The "If-Modified-Since" header field makes a GET or HEAD request
674 method conditional on the selected representation's modification date
675 being more recent than the date provided in the field-value.
676 Transfer of the selected representation's data is avoided if that
677 data has not changed.
679 If-Modified-Since = HTTP-date
681 An example of the field is:
683 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
685 A recipient MUST ignore If-Modified-Since if the request contains an
686 If-None-Match header field; the condition in If-None-Match is
687 considered to be a more accurate replacement for the condition in If-
688 Modified-Since, and the two are only combined for the sake of
689 interoperating with older intermediaries that might not implement If-
690 None-Match.
692 A recipient MUST ignore the If-Modified-Since header field if the
693 received field-value is not a valid HTTP-date, or if the request
694 method is neither GET nor HEAD.
696 A recipient MUST interpret an If-Modified-Since field-value's
697 timestamp in terms of the origin server's clock.
699 If-Modified-Since is typically used for two distinct purposes: 1) to
700 allow efficient updates of a cached representation that does not have
701 an entity-tag and 2) to limit the scope of a web traversal to
702 resources that have recently changed.
704 When used for cache updates, a cache will typically use the value of
705 the cached message's Last-Modified field to generate the field value
706 of If-Modified-Since. This behavior is most interoperable for cases
707 where clocks are poorly synchronized or when the server has chosen to
708 only honor exact timestamp matches (due to a problem with Last-
709 Modified dates that appear to go "back in time" when the origin
710 server's clock is corrected or a representation is restored from an
711 archived backup). However, caches occasionally generate the field
712 value based on other data, such as the Date header field of the
713 cached message or the local clock time that the message was received,
714 particularly when the cached message does not contain a Last-Modified
715 field.
717 When used for limiting the scope of retrieval to a recent time
718 window, a user agent will generate an If-Modified-Since field value
719 based on either its own local clock or a Date header field received
720 from the server in a prior response. Origin servers that choose an
721 exact timestamp match based on the selected representation's Last-
722 Modified field will not be able to help the user agent limit its data
723 transfers to only those changed during the specified window.
725 An origin server that receives an If-Modified-Since header field
726 SHOULD evaluate the condition prior to performing the method
727 (Section 5). The origin server SHOULD NOT perform the requested
728 method if the selected representation's last modification date is
729 earlier than or equal to the date provided in the field-value;
730 instead, the origin server SHOULD generate a 304 (Not Modified)
731 response, including only those metadata that are useful for
732 identifying or updating a previously cached response.
734 Requirements on cache handling of a received If-Modified-Since header
735 field are defined in Section 4.3.2 of [CACHING].
737 3.4. If-Unmodified-Since
739 The "If-Unmodified-Since" header field makes the request method
740 conditional on the selected representation's last modification date
741 being earlier than or equal to the date provided in the field-value.
742 This field accomplishes the same purpose as If-Match for cases where
743 the user agent does not have an entity-tag for the representation.
745 If-Unmodified-Since = HTTP-date
747 An example of the field is:
749 If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
751 A recipient MUST ignore If-Unmodified-Since if the request contains
752 an If-Match header field; the condition in If-Match is considered to
753 be a more accurate replacement for the condition in If-Unmodified-
754 Since, and the two are only combined for the sake of interoperating
755 with older intermediaries that might not implement If-Match.
757 A recipient MUST ignore the If-Unmodified-Since header field if the
758 received field-value is not a valid HTTP-date.
760 A recipient MUST interpret an If-Unmodified-Since field-value's
761 timestamp in terms of the origin server's clock.
763 If-Unmodified-Since is most often used with state-changing methods
764 (e.g., POST, PUT, DELETE) to prevent accidental overwrites when
765 multiple user agents might be acting in parallel on a resource that
766 does not supply entity-tags with its representations (i.e., to
767 prevent the "lost update" problem). It can also be used with safe
768 methods to abort a request if the selected representation does not
769 match one already stored (or partially stored) from a prior request.
771 An origin server that receives an If-Unmodified-Since header field
772 MUST evaluate the condition prior to performing the method
773 (Section 5). The origin server MUST NOT perform the requested method
774 if the selected representation's last modification date is more
775 recent than the date provided in the field-value; instead the origin
776 server MUST respond with either a) the 412 (Precondition Failed)
777 status code or b) one of the 2xx (Successful) status codes if the
778 origin server has verified that a state change is being requested and
779 the final state is already reflected in the current state of the
780 target resource (i.e., the change requested by the user agent has
781 already succeeded, but the user agent might not be aware of that
782 because the prior response message was lost or a compatible change
783 was made by some other user agent). In the latter case, the origin
784 server MUST NOT send a validator header field in the response unless
785 it can verify that the request is a duplicate of an immediately prior
786 change made by the same user agent.
788 The If-Unmodified-Since header field can be ignored by caches and
789 intermediaries because it is not applicable to a stored response.
791 3.5. If-Range
793 The "If-Range" header field provides a special conditional request
794 mechanism that is similar to the If-Match and If-Unmodified-Since
795 header fields but that instructs the recipient to ignore the Range
796 header field if the validator doesn't match, resulting in transfer of
797 the new selected representation instead of a 412 (Precondition
798 Failed) response. If-Range is defined in Section 3.2 of [RANGERQ].
800 4. Status Code Definitions
802 4.1. 304 Not Modified
804 The 304 (Not Modified) status code indicates that a conditional GET
805 or HEAD request has been received and would have resulted in a 200
806 (OK) response if it were not for the fact that the condition
807 evaluated to false. In other words, there is no need for the server
808 to transfer a representation of the target resource because the
809 request indicates that the client, which made the request
810 conditional, already has a valid representation; the server is
811 therefore redirecting the client to make use of that stored
812 representation as if it were the payload of a 200 (OK) response.
814 The server generating a 304 response MUST generate any of the
815 following header fields that would have been sent in a 200 (OK)
816 response to the same request: Cache-Control, Content-Location, Date,
817 ETag, Expires, and Vary.
819 Since the goal of a 304 response is to minimize information transfer
820 when the recipient already has one or more cached representations, a
821 sender SHOULD NOT generate representation metadata other than the
822 above listed fields unless said metadata exists for the purpose of
823 guiding cache updates (e.g., Last-Modified might be useful if the
824 response does not have an ETag field).
826 Requirements on a cache that receives a 304 response are defined in
827 Section 4.3.4 of [CACHING]. If the conditional request originated
828 with an outbound client, such as a user agent with its own cache
829 sending a conditional GET to a shared proxy, then the proxy SHOULD
830 forward the 304 response to that client.
832 A 304 response cannot contain a message-body; it is always terminated
833 by the first empty line after the header fields.
835 4.2. 412 Precondition Failed
837 The 412 (Precondition Failed) status code indicates that one or more
838 conditions given in the request header fields evaluated to false when
839 tested on the server. This response code allows the client to place
840 preconditions on the current resource state (its current
841 representations and metadata) and, thus, prevent the request method
842 from being applied if the target resource is in an unexpected state.
844 5. Evaluation
846 Except when excluded below, a recipient cache or origin server MUST
847 evaluate received request preconditions after it has successfully
848 performed its normal request checks and just before it would perform
849 the action associated with the request method. A server MUST ignore
850 all received preconditions if its response to the same request
851 without those conditions would have been a status code other than a
852 2xx (Successful) or 412 (Precondition Failed). In other words,
853 redirects and failures take precedence over the evaluation of
854 preconditions in conditional requests.
856 A server that is not the origin server for the target resource and
857 cannot act as a cache for requests on the target resource MUST NOT
858 evaluate the conditional request header fields defined by this
859 specification, and it MUST forward them if the request is forwarded,
860 since the generating client intends that they be evaluated by a
861 server that can provide a current representation. Likewise, a server
862 MUST ignore the conditional request header fields defined by this
863 specification when received with a request method that does not
864 involve the selection or modification of a selected representation,
865 such as CONNECT, OPTIONS, or TRACE.
867 Conditional request header fields that are defined by extensions to
868 HTTP might place conditions on all recipients, on the state of the
869 target resource in general, or on a group of resources. For
870 instance, the "If" header field in WebDAV can make a request
871 conditional on various aspects of multiple resources, such as locks,
872 if the recipient understands and implements that field ([RFC4918],
873 Section 10.4).
875 Although conditional request header fields are defined as being
876 usable with the HEAD method (to keep HEAD's semantics consistent with
877 those of GET), there is no point in sending a conditional HEAD
878 because a successful response is around the same size as a 304 (Not
879 Modified) response and more useful than a 412 (Precondition Failed)
880 response.
882 6. Precedence
884 When more than one conditional request header field is present in a
885 request, the order in which the fields are evaluated becomes
886 important. In practice, the fields defined in this document are
887 consistently implemented in a single, logical order, since "lost
888 update" preconditions have more strict requirements than cache
889 validation, a validated cache is more efficient than a partial
890 response, and entity tags are presumed to be more accurate than date
891 validators.
893 A recipient cache or origin server MUST evaluate the request
894 preconditions defined by this specification in the following order:
896 1. When recipient is the origin server and If-Match is present,
897 evaluate the If-Match precondition:
899 * if true, continue to step 3
901 * if false, respond 412 (Precondition Failed) unless it can be
902 determined that the state-changing request has already
903 succeeded (see Section 3.1)
905 2. When recipient is the origin server, If-Match is not present, and
906 If-Unmodified-Since is present, evaluate the If-Unmodified-Since
907 precondition:
909 * if true, continue to step 3
910 * if false, respond 412 (Precondition Failed) unless it can be
911 determined that the state-changing request has already
912 succeeded (see Section 3.4)
914 3. When If-None-Match is present, evaluate the If-None-Match
915 precondition:
917 * if true, continue to step 5
919 * if false for GET/HEAD, respond 304 (Not Modified)
921 * if false for other methods, respond 412 (Precondition Failed)
923 4. When the method is GET or HEAD, If-None-Match is not present, and
924 If-Modified-Since is present, evaluate the If-Modified-Since
925 precondition:
927 * if true, continue to step 5
929 * if false, respond 304 (Not Modified)
931 5. When the method is GET and both Range and If-Range are present,
932 evaluate the If-Range precondition:
934 * if the validator matches and the Range specification is
935 applicable to the selected representation, respond 206
936 (Partial Content) [RANGERQ]
938 6. Otherwise,
940 * all conditions are met, so perform the requested action and
941 respond according to its success or failure.
943 Any extension to HTTP/1.1 that defines additional conditional request
944 header fields ought to define its own expectations regarding the
945 order for evaluating such fields in relation to those defined in this
946 document and other conditionals that might be found in practice.
948 7. IANA Considerations
950 7.1. Status Code Registration
952 The "Hypertext Transfer Protocol (HTTP) Status Code Registry" located
953 at has been
954 updated with the registrations below:
956 +-------+---------------------+--------------+
957 | Value | Description | Reference |
958 +-------+---------------------+--------------+
959 | 304 | Not Modified | Section 4.1 |
960 | 412 | Precondition Failed | Section 4.2 |
961 +-------+---------------------+--------------+
963 7.2. Header Field Registration
965 HTTP header fields are registered within the "Message Headers"
966 registry maintained at .
969 This document defines the following HTTP header fields, so their
970 associated registry entries have been updated according to the
971 permanent registrations below (see [BCP90]):
973 +---------------------+----------+----------+--------------+
974 | Header Field Name | Protocol | Status | Reference |
975 +---------------------+----------+----------+--------------+
976 | ETag | http | standard | Section 2.3 |
977 | If-Match | http | standard | Section 3.1 |
978 | If-Modified-Since | http | standard | Section 3.3 |
979 | If-None-Match | http | standard | Section 3.2 |
980 | If-Unmodified-Since | http | standard | Section 3.4 |
981 | Last-Modified | http | standard | Section 2.2 |
982 +---------------------+----------+----------+--------------+
984 The change controller is: "IETF (iesg@ietf.org) - Internet
985 Engineering Task Force".
987 8. Security Considerations
989 This section is meant to inform developers, information providers,
990 and users of known security concerns specific to the HTTP conditional
991 request mechanisms. More general security considerations are
992 addressed in HTTP "Message Syntax and Routing" [MESSGNG] and
993 "Semantics and Content" [SEMNTCS].
995 The validators defined by this specification are not intended to
996 ensure the validity of a representation, guard against malicious
997 changes, or detect man-in-the-middle attacks. At best, they enable
998 more efficient cache updates and optimistic concurrent writes when
999 all participants are behaving nicely. At worst, the conditions will
1000 fail and the client will receive a response that is no more harmful
1001 than an HTTP exchange without conditional requests.
1003 An entity-tag can be abused in ways that create privacy risks. For
1004 example, a site might deliberately construct a semantically invalid
1005 entity-tag that is unique to the user or user agent, send it in a
1006 cacheable response with a long freshness time, and then read that
1007 entity-tag in later conditional requests as a means of re-identifying
1008 that user or user agent. Such an identifying tag would become a
1009 persistent identifier for as long as the user agent retained the
1010 original cache entry. User agents that cache representations ought
1011 to ensure that the cache is cleared or replaced whenever the user
1012 performs privacy-maintaining actions, such as clearing stored cookies
1013 or changing to a private browsing mode.
1015 9. References
1017 9.1. Normative References
1019 [CACHING] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
1020 Ed., "Hypertext Transfer Protocol (HTTP): Caching", draft-
1021 ietf-httpbis-cache-00 (work in progress), April 2018.
1023 [MESSGNG] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
1024 Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message
1025 Syntax and Routing", draft-ietf-httpbis-messaging-00 (work
1026 in progress), April 2018.
1028 [RANGERQ] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
1029 Ed., "Hypertext Transfer Protocol (HTTP): Range Requests",
1030 draft-ietf-httpbis-range-00 (work in progress), April
1031 2018.
1033 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
1034 Requirement Levels", BCP 14, RFC 2119,
1035 DOI 10.17487/RFC2119, March 1997,
1036 .
1038 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
1039 Specifications: ABNF", STD 68, RFC 5234,
1040 DOI 10.17487/RFC5234, January 2008,
1041 .
1043 [SEMNTCS] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
1044 Ed., "Hypertext Transfer Protocol (HTTP): Semantics and
1045 Content", draft-ietf-httpbis-semantics-00 (work in
1046 progress), April 2018.
1048 9.2. Informative References
1050 [BCP90] Klyne, G., Nottingham, M., and J. Mogul, "Registration
1051 Procedures for Message Header Fields", BCP 90, RFC 3864,
1052 September 2004, .
1054 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
1055 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
1056 Transfer Protocol -- HTTP/1.1", RFC 2616,
1057 DOI 10.17487/RFC2616, June 1999,
1058 .
1060 [RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed
1061 Authoring and Versioning (WebDAV)", RFC 4918,
1062 DOI 10.17487/RFC4918, June 2007,
1063 .
1065 [RFC7232] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
1066 Protocol (HTTP/1.1): Conditional Requests", RFC 7232,
1067 DOI 10.17487/RFC7232, June 2014,
1068 .
1070 Appendix A. Changes from RFC 7232
1072 None yet.
1074 Appendix B. Imported ABNF
1076 The following core rules are included by reference, as defined in
1077 Appendix B.1 of [RFC5234]: ALPHA (letters), CR (carriage return),
1078 CRLF (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double
1079 quote), HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed), OCTET (any
1080 8-bit sequence of data), SP (space), and VCHAR (any visible US-ASCII
1081 character).
1083 The rules below are defined in [MESSGNG]:
1085 OWS =
1086 obs-text =
1088 The rules below are defined in other parts:
1090 HTTP-date =
1092 Appendix C. Collected ABNF
1094 In the collected ABNF below, list rules are expanded as per
1095 Section 1.2 of [MESSGNG].
1097 ETag = entity-tag
1099 HTTP-date =
1101 If-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
1102 entity-tag ] ) )
1103 If-Modified-Since = HTTP-date
1104 If-None-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
1105 entity-tag ] ) )
1106 If-Unmodified-Since = HTTP-date
1108 Last-Modified = HTTP-date
1110 OWS =
1112 entity-tag = [ weak ] opaque-tag
1113 etagc = "!" / %x23-7E ; '#'-'~'
1114 / obs-text
1116 obs-text =
1117 opaque-tag = DQUOTE *etagc DQUOTE
1119 weak = %x57.2F ; W/
1121 Appendix D. Change Log
1123 This section is to be removed before publishing as an RFC.
1125 D.1. Since RFC 7232
1127 The changes in this draft are purely editorial:
1129 o Change boilerplate and abstract to indicate the "draft" status,
1130 and update references to ancestor specifications.
1132 o Remove version "1.1" from document title, indicating that this
1133 specification applies to all HTTP versions.
1135 o Adjust historical notes.
1137 o Update links to sibling specifications.
1139 o Replace sections listing changes from RFC 2616 by new empty
1140 sections referring to RFC 723x.
1142 o Remove acknowledgements specific to RFC 723x.
1144 o Move "Acknowledgements" to the very end and make them unnumbered.
1146 Index
1148 3
1149 304 Not Modified (status code) 17
1151 4
1152 412 Precondition Failed (status code) 18
1154 E
1155 ETag header field 8
1157 G
1158 Grammar
1159 entity-tag 9
1160 ETag 9
1161 etagc 9
1162 If-Match 12
1163 If-Modified-Since 15
1164 If-None-Match 14
1165 If-Unmodified-Since 16
1166 Last-Modified 6
1167 opaque-tag 9
1168 weak 9
1170 I
1171 If-Match header field 12
1172 If-Modified-Since header field 15
1173 If-None-Match header field 13
1174 If-Unmodified-Since header field 16
1176 L
1177 Last-Modified header field 6
1179 M
1180 metadata 4
1182 S
1183 selected representation 3
1185 V
1186 validator 4
1187 strong 5
1188 weak 5
1190 Acknowledgments
1192 See Appendix "Acknowledgments" of [MESSGNG].
1194 Authors' Addresses
1196 Roy T. Fielding (editor)
1197 Adobe
1198 345 Park Ave
1199 San Jose, CA 95110
1200 USA
1202 EMail: fielding@gbiv.com
1203 URI: http://roy.gbiv.com/
1205 Mark Nottingham (editor)
1206 Fastly
1208 EMail: mnot@mnot.net
1209 URI: https://www.mnot.net/
1211 Julian F. Reschke (editor)
1212 greenbytes GmbH
1213 Hafenweg 16
1214 Muenster, NW 48155
1215 Germany
1217 EMail: julian.reschke@greenbytes.de
1218 URI: http://greenbytes.de/tech/webdav/