idnits 2.17.1
draft-ietf-httpbis-p4-conditional-25.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 :
----------------------------------------------------------------------------
-- The draft header indicates that this document obsoletes RFC2616, but the
abstract doesn't seem to mention this, which it should.
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, and may
have content which was first submitted before 10 November 2008. The
disclaimer is necessary when there are original authors that you have
been unable to contact, or if some do not wish to grant the BCP78 rights
to the IETF Trust. If you are able to get all authors (current and
original) to grant those rights, 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 (November 17, 2013) is 3812 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)
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p1-messaging-25
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p2-semantics-25
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p5-range-25
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p6-cache-25
-- Obsolete informational reference (is this intentional?): RFC 2616
(Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235)
Summary: 0 errors (**), 0 flaws (~~), 5 warnings (==), 4 comments (--).
Run idnits with the --verbose option for more detailed information about
the items above.
--------------------------------------------------------------------------------
2 HTTPbis Working Group R. Fielding, Ed.
3 Internet-Draft Adobe
4 Obsoletes: 2616 (if approved) J. Reschke, Ed.
5 Intended status: Standards Track greenbytes
6 Expires: May 21, 2014 November 17, 2013
8 Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests
9 draft-ietf-httpbis-p4-conditional-25
11 Abstract
13 The Hypertext Transfer Protocol (HTTP) is an application-level
14 protocol for distributed, collaborative, hypertext information
15 systems. This document defines HTTP/1.1 conditional requests,
16 including metadata header fields for indicating state changes,
17 request header fields for making preconditions on such state, and
18 rules for constructing the responses to a conditional request when
19 one or more preconditions evaluate to false.
21 Editorial Note (To be removed by RFC Editor)
23 Discussion of this draft takes place on the HTTPBIS working group
24 mailing list (ietf-http-wg@w3.org), which is archived at
25 .
27 The current issues list is at
28 and related
29 documents (including fancy diffs) can be found at
30 .
32 The changes in this draft are summarized in Appendix D.1.
34 Status of This Memo
36 This Internet-Draft is submitted in full conformance with the
37 provisions of BCP 78 and BCP 79.
39 Internet-Drafts are working documents of the Internet Engineering
40 Task Force (IETF). Note that other groups may also distribute
41 working documents as Internet-Drafts. The list of current Internet-
42 Drafts is at http://datatracker.ietf.org/drafts/current/.
44 Internet-Drafts are draft documents valid for a maximum of six months
45 and may be updated, replaced, or obsoleted by other documents at any
46 time. It is inappropriate to use Internet-Drafts as reference
47 material or to cite them other than as "work in progress."
48 This Internet-Draft will expire on May 21, 2014.
50 Copyright Notice
52 Copyright (c) 2013 IETF Trust and the persons identified as the
53 document authors. All rights reserved.
55 This document is subject to BCP 78 and the IETF Trust's Legal
56 Provisions Relating to IETF Documents
57 (http://trustee.ietf.org/license-info) in effect on the date of
58 publication of this document. Please review these documents
59 carefully, as they describe your rights and restrictions with respect
60 to this document. Code Components extracted from this document must
61 include Simplified BSD License text as described in Section 4.e of
62 the Trust Legal Provisions and are provided without warranty as
63 described in the Simplified BSD License.
65 This document may contain material from IETF Documents or IETF
66 Contributions published or made publicly available before November
67 10, 2008. The person(s) controlling the copyright in some of this
68 material may not have granted the IETF Trust the right to allow
69 modifications of such material outside the IETF Standards Process.
70 Without obtaining an adequate license from the person(s) controlling
71 the copyright in such materials, this document may not be modified
72 outside the IETF Standards Process, and derivative works of it may
73 not be created outside the IETF Standards Process, except to format
74 it for publication as an RFC or to translate it into languages other
75 than English.
77 Table of Contents
79 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4
80 1.1. Conformance and Error Handling . . . . . . . . . . . . . . 4
81 1.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 4
82 2. Validators . . . . . . . . . . . . . . . . . . . . . . . . . . 5
83 2.1. Weak versus Strong . . . . . . . . . . . . . . . . . . . . 5
84 2.2. Last-Modified . . . . . . . . . . . . . . . . . . . . . . 7
85 2.2.1. Generation . . . . . . . . . . . . . . . . . . . . . . 7
86 2.2.2. Comparison . . . . . . . . . . . . . . . . . . . . . . 8
87 2.3. ETag . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
88 2.3.1. Generation . . . . . . . . . . . . . . . . . . . . . . 9
89 2.3.2. Comparison . . . . . . . . . . . . . . . . . . . . . . 10
90 2.3.3. Example: Entity-tags Varying on Content-Negotiated
91 Resources . . . . . . . . . . . . . . . . . . . . . . 11
92 2.4. When to Use Entity-tags and Last-Modified Dates . . . . . 12
93 3. Precondition Header Fields . . . . . . . . . . . . . . . . . . 13
94 3.1. If-Match . . . . . . . . . . . . . . . . . . . . . . . . . 13
95 3.2. If-None-Match . . . . . . . . . . . . . . . . . . . . . . 14
96 3.3. If-Modified-Since . . . . . . . . . . . . . . . . . . . . 15
97 3.4. If-Unmodified-Since . . . . . . . . . . . . . . . . . . . 16
98 3.5. If-Range . . . . . . . . . . . . . . . . . . . . . . . . . 18
99 4. Status Code Definitions . . . . . . . . . . . . . . . . . . . 18
100 4.1. 304 Not Modified . . . . . . . . . . . . . . . . . . . . . 18
101 4.2. 412 Precondition Failed . . . . . . . . . . . . . . . . . 18
102 5. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 19
103 6. Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . 19
104 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 21
105 7.1. Status Code Registration . . . . . . . . . . . . . . . . . 21
106 7.2. Header Field Registration . . . . . . . . . . . . . . . . 21
107 8. Security Considerations . . . . . . . . . . . . . . . . . . . 22
108 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 22
109 10. References . . . . . . . . . . . . . . . . . . . . . . . . . . 23
110 10.1. Normative References . . . . . . . . . . . . . . . . . . . 23
111 10.2. Informative References . . . . . . . . . . . . . . . . . . 23
112 Appendix A. Changes from RFC 2616 . . . . . . . . . . . . . . . . 23
113 Appendix B. Imported ABNF . . . . . . . . . . . . . . . . . . . . 24
114 Appendix C. Collected ABNF . . . . . . . . . . . . . . . . . . . 24
115 Appendix D. Change Log (to be removed by RFC Editor before
116 publication) . . . . . . . . . . . . . . . . . . . . 25
117 D.1. Since draft-ietf-httpbis-p4-conditional-24 . . . . . . . . 25
118 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
120 1. Introduction
122 Conditional requests are HTTP requests [Part2] that include one or
123 more header fields indicating a precondition to be tested before
124 applying the method semantics to the target resource. This document
125 defines the HTTP/1.1 conditional request mechanisms in terms of the
126 architecture, syntax notation, and conformance criteria defined in
127 [Part1].
129 Conditional GET requests are the most efficient mechanism for HTTP
130 cache updates [Part6]. Conditionals can also be applied to state-
131 changing methods, such as PUT and DELETE, to prevent the "lost
132 update" problem: one client accidentally overwriting the work of
133 another client that has been acting in parallel.
135 Conditional request preconditions are based on the state of the
136 target resource as a whole (its current value set) or the state as
137 observed in a previously obtained representation (one value in that
138 set). A resource might have multiple current representations, each
139 with its own observable state. The conditional request mechanisms
140 assume that the mapping of requests to a "selected representation"
141 (Section 3 of [Part2]) will be consistent over time if the server
142 intends to take advantage of conditionals. Regardless, if the
143 mapping is inconsistent and the server is unable to select the
144 appropriate representation, then no harm will result when the
145 precondition evaluates to false.
147 The conditional request preconditions defined by this specification
148 (Section 3) are evaluated when applicable to the recipient
149 (Section 5) according to their order of precedence (Section 6).
151 1.1. Conformance and Error Handling
153 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
154 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
155 document are to be interpreted as described in [RFC2119].
157 Conformance criteria and considerations regarding error handling are
158 defined in Section 2.5 of [Part1].
160 1.2. Syntax Notation
162 This specification uses the Augmented Backus-Naur Form (ABNF)
163 notation of [RFC5234] with the list rule extension defined in Section
164 7 of [Part1]. Appendix B describes rules imported from other
165 documents. Appendix C shows the collected ABNF with the list rule
166 expanded.
168 2. Validators
170 This specification defines two forms of metadata that are commonly
171 used to observe resource state and test for preconditions:
172 modification dates (Section 2.2) and opaque entity tags
173 (Section 2.3). Additional metadata that reflects resource state has
174 been defined by various extensions of HTTP, such as WebDAV [RFC4918],
175 that are beyond the scope of this specification. A resource metadata
176 value is referred to as a "validator" when it is used within a
177 precondition.
179 2.1. Weak versus Strong
181 Validators come in two flavors: strong or weak. Weak validators are
182 easy to generate but are far less useful for comparisons. Strong
183 validators are ideal for comparisons but can be very difficult (and
184 occasionally impossible) to generate efficiently. Rather than impose
185 that all forms of resource adhere to the same strength of validator,
186 HTTP exposes the type of validator in use and imposes restrictions on
187 when weak validators can be used as preconditions.
189 A "strong validator" is representation metadata that changes value
190 whenever a change occurs to the representation data that would be
191 observable in the payload body of a 200 (OK) response to GET.
193 A strong validator might change for reasons other than a change to
194 the representation data, such as when a semantically significant part
195 of the representation metadata is changed (e.g., Content-Type), but
196 it is in the best interests of the origin server to only change the
197 value when it is necessary to invalidate the stored responses held by
198 remote caches and authoring tools.
200 Cache entries might persist for arbitrarily long periods, regardless
201 of expiration times. Thus, a cache might attempt to validate an
202 entry using a validator that it obtained in the distant past. A
203 strong validator is unique across all versions of all representations
204 associated with a particular resource over time. However, there is
205 no implication of uniqueness across representations of different
206 resources (i.e., the same strong validator might be in use for
207 representations of multiple resources at the same time and does not
208 imply that those representations are equivalent).
210 There are a variety of strong validators used in practice. The best
211 are based on strict revision control, wherein each change to a
212 representation always results in a unique node name and revision
213 identifier being assigned before the representation is made
214 accessible to GET. A collision-resistant hash function applied to
215 the representation data is also sufficient if the data is available
216 prior to the response header fields being sent and the digest does
217 not need to be recalculated every time a validation request is
218 received. However, if a resource has distinct representations that
219 differ only in their metadata, such as might occur with content
220 negotiation over media types that happen to share the same data
221 format, then the origin server needs to incorporate additional
222 information in the validator to distinguish those representations.
224 In contrast, a "weak validator" is representation metadata that might
225 not change for every change to the representation data. This
226 weakness might be due to limitations in how the value is calculated,
227 such as clock resolution or an inability to ensure uniqueness for all
228 possible representations of the resource, or due to a desire by the
229 resource owner to group representations by some self-determined set
230 of equivalency rather than unique sequences of data. An origin
231 server SHOULD change a weak entity-tag whenever it considers prior
232 representations to be unacceptable as a substitute for the current
233 representation. In other words, a weak entity-tag ought to change
234 whenever the origin server wants caches to invalidate old responses.
236 For example, the representation of a weather report that changes in
237 content every second, based on dynamic measurements, might be grouped
238 into sets of equivalent representations (from the origin server's
239 perspective) with the same weak validator in order to allow cached
240 representations to be valid for a reasonable period of time (perhaps
241 adjusted dynamically based on server load or weather quality).
242 Likewise, a representation's modification time, if defined with only
243 one-second resolution, might be a weak validator if it is possible
244 for the representation to be modified twice during a single second
245 and retrieved between those modifications.
247 Likewise, a validator is weak if it is shared by two or more
248 representations of a given resource at the same time, unless those
249 representations have identical representation data. For example, if
250 the origin server sends the same validator for a representation with
251 a gzip content coding applied as it does for a representation with no
252 content coding, then that validator is weak. However, two
253 simultaneous representations might share the same strong validator if
254 they differ only in the representation metadata, such as when two
255 different media types are available for the same representation data.
257 Strong validators are usable for all conditional requests, including
258 cache validation, partial content ranges, and "lost update"
259 avoidance. Weak validators are only usable when the client does not
260 require exact equality with previously obtained representation data,
261 such as when validating a cache entry or limiting a web traversal to
262 recent changes.
264 2.2. Last-Modified
266 The "Last-Modified" header field in a response provides a timestamp
267 indicating the date and time at which the origin server believes the
268 selected representation was last modified, as determined at the
269 conclusion of handling the request.
271 Last-Modified = HTTP-date
273 An example of its use is
275 Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
277 2.2.1. Generation
279 An origin server SHOULD send Last-Modified for any selected
280 representation for which a last modification date can be reasonably
281 and consistently determined, since its use in conditional requests
282 and evaluating cache freshness ([Part6]) results in a substantial
283 reduction of HTTP traffic on the Internet and can be a significant
284 factor in improving service scalability and reliability.
286 A representation is typically the sum of many parts behind the
287 resource interface. The last-modified time would usually be the most
288 recent time that any of those parts were changed. How that value is
289 determined for any given resource is an implementation detail beyond
290 the scope of this specification. What matters to HTTP is how
291 recipients of the Last-Modified header field can use its value to
292 make conditional requests and test the validity of locally cached
293 responses.
295 An origin server SHOULD obtain the Last-Modified value of the
296 representation as close as possible to the time that it generates the
297 Date field value for its response. This allows a recipient to make
298 an accurate assessment of the representation's modification time,
299 especially if the representation changes near the time that the
300 response is generated.
302 An origin server with a clock MUST NOT send a Last-Modified date that
303 is later than the server's time of message origination (Date). If
304 the last modification time is derived from implementation-specific
305 metadata that evaluates to some time in the future, according to the
306 origin server's clock, then the origin server MUST replace that value
307 with the message origination date. This prevents a future
308 modification date from having an adverse impact on cache validation.
310 An origin server without a clock MUST NOT assign Last-Modified values
311 to a response unless these values were associated with the resource
312 by some other system or user with a reliable clock.
314 2.2.2. Comparison
316 A Last-Modified time, when used as a validator in a request, is
317 implicitly weak unless it is possible to deduce that it is strong,
318 using the following rules:
320 o The validator is being compared by an origin server to the actual
321 current validator for the representation and,
323 o That origin server reliably knows that the associated
324 representation did not change twice during the second covered by
325 the presented validator.
327 or
329 o The validator is about to be used by a client in an If-Modified-
330 Since, If-Unmodified-Since header field, because the client has a
331 cache entry, or If-Range for the associated representation, and
333 o That cache entry includes a Date value, which gives the time when
334 the origin server sent the original response, and
336 o The presented Last-Modified time is at least 60 seconds before the
337 Date value.
339 or
341 o The validator is being compared by an intermediate cache to the
342 validator stored in its cache entry for the representation, and
344 o That cache entry includes a Date value, which gives the time when
345 the origin server sent the original response, and
347 o The presented Last-Modified time is at least 60 seconds before the
348 Date value.
350 This method relies on the fact that if two different responses were
351 sent by the origin server during the same second, but both had the
352 same Last-Modified time, then at least one of those responses would
353 have a Date value equal to its Last-Modified time. The arbitrary 60-
354 second limit guards against the possibility that the Date and Last-
355 Modified values are generated from different clocks, or at somewhat
356 different times during the preparation of the response. An
357 implementation MAY use a value larger than 60 seconds, if it is
358 believed that 60 seconds is too short.
360 2.3. ETag
362 The "ETag" header field in a response provides the current entity-tag
363 for the selected representation, as determined at the conclusion of
364 handling the request. An entity-tag is an opaque validator for
365 differentiating between multiple representations of the same
366 resource, regardless of whether those multiple representations are
367 due to resource state changes over time, content negotiation
368 resulting in multiple representations being valid at the same time,
369 or both. An entity-tag consists of an opaque quoted string, possibly
370 prefixed by a weakness indicator.
372 ETag = entity-tag
374 entity-tag = [ weak ] opaque-tag
375 weak = %x57.2F ; "W/", case-sensitive
376 opaque-tag = DQUOTE *etagc DQUOTE
377 etagc = %x21 / %x23-7E / obs-text
378 ; VCHAR except double quotes, plus obs-text
380 Note: Previously, opaque-tag was defined to be a quoted-string
381 ([RFC2616], Section 3.11), thus some recipients might perform
382 backslash unescaping. Servers therefore ought to avoid backslash
383 characters in entity tags.
385 An entity-tag can be more reliable for validation than a modification
386 date in situations where it is inconvenient to store modification
387 dates, where the one-second resolution of HTTP date values is not
388 sufficient, or where modification dates are not consistently
389 maintained.
391 Examples:
393 ETag: "xyzzy"
394 ETag: W/"xyzzy"
395 ETag: ""
397 An entity-tag can be either a weak or strong validator, with strong
398 being the default. If an origin server provides an entity-tag for a
399 representation and the generation of that entity-tag does not satisfy
400 all of the characteristics of a strong validator (Section 2.1), then
401 the origin server MUST mark the entity-tag as weak by prefixing its
402 opaque value with "W/" (case-sensitive).
404 2.3.1. Generation
406 The principle behind entity-tags is that only the service author
407 knows the implementation of a resource well enough to select the most
408 accurate and efficient validation mechanism for that resource, and
409 that any such mechanism can be mapped to a simple sequence of octets
410 for easy comparison. Since the value is opaque, there is no need for
411 the client to be aware of how each entity-tag is constructed.
413 For example, a resource that has implementation-specific versioning
414 applied to all changes might use an internal revision number, perhaps
415 combined with a variance identifier for content negotiation, to
416 accurately differentiate between representations. Other
417 implementations might use a collision-resistant hash of
418 representation content, a combination of various filesystem
419 attributes, or a modification timestamp that has sub-second
420 resolution.
422 An origin server SHOULD send ETag for any selected representation for
423 which detection of changes can be reasonably and consistently
424 determined, since the entity-tag's use in conditional requests and
425 evaluating cache freshness ([Part6]) can result in a substantial
426 reduction of HTTP network traffic and can be a significant factor in
427 improving service scalability and reliability.
429 2.3.2. Comparison
431 There are two entity-tag comparison functions, depending on whether
432 the comparison context allows the use of weak validators or not:
434 o Strong comparison: two entity-tags are equivalent if both are not
435 weak and their opaque-tags match character-by-character.
437 o Weak comparison: two entity-tags are equivalent if their opaque-
438 tags match character-by-character, regardless of either or both
439 being tagged as "weak".
441 The example below shows the results for a set of entity-tag pairs,
442 and both the weak and strong comparison function results:
444 +--------+--------+-------------------+-----------------+
445 | ETag 1 | ETag 2 | Strong Comparison | Weak Comparison |
446 +--------+--------+-------------------+-----------------+
447 | W/"1" | W/"1" | no match | match |
448 | W/"1" | W/"2" | no match | no match |
449 | W/"1" | "1" | no match | match |
450 | "1" | "1" | match | match |
451 +--------+--------+-------------------+-----------------+
453 2.3.3. Example: Entity-tags Varying on Content-Negotiated Resources
455 Consider a resource that is subject to content negotiation (Section
456 3.4 of [Part2]), and where the representations sent in response to a
457 GET request vary based on the Accept-Encoding request header field
458 (Section 5.3.4 of [Part2]):
460 >> Request:
462 GET /index HTTP/1.1
463 Host: www.example.com
464 Accept-Encoding: gzip
466 In this case, the response might or might not use the gzip content
467 coding. If it does not, the response might look like:
469 >> Response:
471 HTTP/1.1 200 OK
472 Date: Fri, 26 Mar 2010 00:05:00 GMT
473 ETag: "123-a"
474 Content-Length: 70
475 Vary: Accept-Encoding
476 Content-Type: text/plain
478 Hello World!
479 Hello World!
480 Hello World!
481 Hello World!
482 Hello World!
484 An alternative representation that does use gzip content coding would
485 be:
487 >> Response:
489 HTTP/1.1 200 OK
490 Date: Fri, 26 Mar 2010 00:05:00 GMT
491 ETag: "123-b"
492 Content-Length: 43
493 Vary: Accept-Encoding
494 Content-Type: text/plain
495 Content-Encoding: gzip
497 ...binary data...
499 Note: Content codings are a property of the representation data,
500 so a strong entity-tag for a content-encoded representation has to
501 be distinct from the entity tag of an unencoded representation to
502 prevent potential conflicts during cache updates and range
503 requests. In contrast, transfer codings (Section 4 of [Part1])
504 apply only during message transfer and do not result in distinct
505 entity-tags.
507 2.4. When to Use Entity-tags and Last-Modified Dates
509 We adopt a set of rules and recommendations for origin servers,
510 clients, and caches regarding when various validator types ought to
511 be used, and for what purposes.
513 In 200 (OK) responses to GET or HEAD, an origin server:
515 o SHOULD send an entity-tag validator unless it is not feasible to
516 generate one.
518 o MAY send a weak entity-tag instead of a strong entity-tag, if
519 performance considerations support the use of weak entity-tags, or
520 if it is unfeasible to send a strong entity-tag.
522 o SHOULD send a Last-Modified value if it is feasible to send one.
524 In other words, the preferred behavior for an origin server is to
525 send both a strong entity-tag and a Last-Modified value in successful
526 responses to a retrieval request.
528 A client:
530 o MUST send that entity-tag in any cache validation request (using
531 If-Match or If-None-Match) if an entity-tag has been provided by
532 the origin server.
534 o SHOULD send the Last-Modified value in non-subrange cache
535 validation requests (using If-Modified-Since) if only a Last-
536 Modified value has been provided by the origin server.
538 o MAY send the Last-Modified value in subrange cache validation
539 requests (using If-Unmodified-Since) if only a Last-Modified value
540 has been provided by an HTTP/1.0 origin server. The user agent
541 SHOULD provide a way to disable this, in case of difficulty.
543 o SHOULD send both validators in cache validation requests if both
544 an entity-tag and a Last-Modified value have been provided by the
545 origin server. This allows both HTTP/1.0 and HTTP/1.1 caches to
546 respond appropriately.
548 3. Precondition Header Fields
550 This section defines the syntax and semantics of HTTP/1.1 header
551 fields for applying preconditions on requests. Section 5 defines
552 when the preconditions are applied. Section 6 defines the order of
553 evaluation when more than one precondition is present.
555 3.1. If-Match
557 The "If-Match" header field makes the request method conditional on
558 the recipient origin server either having at least one current
559 representation of the target resource, when the field-value is "*",
560 or having a current representation of the target resource that has an
561 entity-tag matching a member of the list of entity-tags provided in
562 the field-value.
564 An origin server MUST use the strong comparison function when
565 comparing entity-tags for If-Match (Section 2.3.2), since the client
566 intends this precondition to prevent the method from being applied if
567 there have been any changes to the representation data.
569 If-Match = "*" / 1#entity-tag
571 Examples:
573 If-Match: "xyzzy"
574 If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
575 If-Match: *
577 If-Match is most often used with state-changing methods (e.g., POST,
578 PUT, DELETE) to prevent accidental overwrites when multiple user
579 agents might be acting in parallel on the same resource (i.e., to
580 prevent the "lost update" problem). It can also be used with safe
581 methods to abort a request if the selected representation does not
582 match one already stored (or partially stored) from a prior request.
584 An origin server that receives an If-Match header field MUST evaluate
585 the condition prior to performing the method (Section 5). If the
586 field-value is "*", the condition is false if the origin server does
587 not have a current representation for the target resource. If the
588 field-value is a list of entity-tags, the condition is false if none
589 of the listed tags match the entity-tag of the selected
590 representation.
592 An origin server MUST NOT perform the requested method if a received
593 If-Match condition evaluates to false; instead the origin server MUST
594 respond with either: a) the 412 (Precondition Failed) status code;
595 or, b) one of the 2xx (Successful) status codes if the origin server
596 has verified that a state change is being requested and the final
597 state is already reflected in the current state of the target
598 resource (i.e., the change requested by the user agent has already
599 succeeded, but the user agent might not be aware of it, perhaps
600 because the prior response was lost or a compatible change was made
601 by some other user agent). In the latter case, the origin server
602 MUST NOT send a validator header field in the response unless it can
603 verify that the request is a duplicate of an immediately prior change
604 made by the same user agent.
606 The If-Match header field can be ignored by caches and intermediaries
607 because it is not applicable to a stored response.
609 3.2. If-None-Match
611 The "If-None-Match" header field makes the request method conditional
612 on a recipient cache or origin server either not having any current
613 representation of the target resource, when the field-value is "*",
614 or having a selected representation with an entity-tag that does not
615 match any of those listed in the field-value.
617 A recipient MUST use the weak comparison function when comparing
618 entity-tags for If-None-Match (Section 2.3.2), since weak entity-tags
619 can be used for cache validation even if there have been changes to
620 the representation data.
622 If-None-Match = "*" / 1#entity-tag
624 Examples:
626 If-None-Match: "xyzzy"
627 If-None-Match: W/"xyzzy"
628 If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
629 If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"
630 If-None-Match: *
632 If-None-Match is primarily used in conditional GET requests to enable
633 efficient updates of cached information with a minimum amount of
634 transaction overhead. When a client desires to update one or more
635 stored responses that have entity-tags, the client SHOULD generate an
636 If-None-Match header field containing a list of those entity-tags
637 when making a GET request; this allows recipient servers to send a
638 304 (Not Modified) response to indicate when one of those stored
639 responses matches the selected representation.
641 If-None-Match can also be used with a value of "*" to prevent an
642 unsafe request method (e.g., PUT) from inadvertently modifying an
643 existing representation of the target resource when the client
644 believes that the resource does not have a current representation
645 (Section 4.2.1 of [Part2]). This is a variation on the "lost update"
646 problem that might arise if more than one client attempts to create
647 an initial representation for the target resource.
649 An origin server that receives an If-None-Match header field MUST
650 evaluate the condition prior to performing the method (Section 5).
651 If the field-value is "*", the condition is false if the origin
652 server has a current representation for the target resource. If the
653 field-value is a list of entity-tags, the condition is false if one
654 of the listed tags match the entity-tag of the selected
655 representation.
657 An origin server MUST NOT perform the requested method if the
658 condition evaluates to false; instead, the origin server MUST respond
659 with either a) the 304 (Not Modified) status code if the request
660 method is GET or HEAD; or, b) the 412 (Precondition Failed) status
661 code for all other request methods.
663 Requirements on cache handling of a received If-None-Match header
664 field are defined in Section 4.3.2 of [Part6].
666 3.3. If-Modified-Since
668 The "If-Modified-Since" header field makes a GET or HEAD request
669 method conditional on the selected representation's modification date
670 being more recent than the date provided in the field-value.
671 Transfer of the selected representation's data is avoided if that
672 data has not changed.
674 If-Modified-Since = HTTP-date
676 An example of the field is:
678 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
680 A recipient MUST ignore If-Modified-Since if the request contains an
681 If-None-Match header field; the condition in If-None-Match is
682 considered to be a more accurate replacement for the condition in If-
683 Modified-Since and the two are only combined for the sake of
684 interoperating with older intermediaries that might not implement If-
685 None-Match.
687 A recipient MUST ignore the If-Modified-Since header field if the
688 received field-value is not a valid HTTP-date, or if the request
689 method is neither GET nor HEAD.
691 A recipient MUST interpret an If-Modified-Since field-value's
692 timestamp in terms of the origin server's clock.
694 If-Modified-Since is typically used for two distinct purposes: 1) to
695 allow efficient updates of a cached representation that does not have
696 an entity-tag; and, 2) to limit the scope of a web traversal to
697 resources that have recently changed.
699 When used for cache updates, a cache will typically use the value of
700 the cached message's Last-Modified field to generate the field value
701 of If-Modified-Since. This behavior is most interoperable for cases
702 where clocks are poorly synchronized or when the server has chosen to
703 only honor exact timestamp matches (due to a problem with Last-
704 Modified dates that appear to go "back in time" when the origin
705 server's clock is corrected or a representation is restored from an
706 archived backup). However, caches occasionally generate the field
707 value based on other data, such as the Date header field of the
708 cached message or the local clock time that the message was received,
709 particularly when the cached message does not contain a Last-Modified
710 field.
712 When used for limiting the scope of retrieval to a recent time
713 window, a user agent will generate an If-Modified-Since field value
714 based on either its own local clock or a Date header field received
715 from the server in a prior response. Origin servers that choose an
716 exact timestamp match based on the selected representation's Last-
717 Modified field will not be able to help the user agent limit its data
718 transfers to only those changed during the specified window.
720 An origin server that receives an If-Modified-Since header field
721 SHOULD evaluate the condition prior to performing the method
722 (Section 5). The origin server SHOULD NOT perform the requested
723 method if the selected representation's last modification date is
724 earlier than or equal to the date provided in the field-value;
725 instead, the origin server SHOULD generate a 304 (Not Modified)
726 response, including only those metadata that are useful for
727 identifying or updating a previously cached response.
729 Requirements on cache handling of a received If-Modified-Since header
730 field are defined in Section 4.3.2 of [Part6].
732 3.4. If-Unmodified-Since
734 The "If-Unmodified-Since" header field makes the request method
735 conditional on the selected representation's last modification date
736 being earlier than or equal to the date provided in the field-value.
737 This field accomplishes the same purpose as If-Match for cases where
738 the user agent does not have an entity-tag for the representation.
740 If-Unmodified-Since = HTTP-date
742 An example of the field is:
744 If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
746 A recipient MUST ignore If-Unmodified-Since if the request contains
747 an If-Match header field; the condition in If-Match is considered to
748 be a more accurate replacement for the condition in If-Unmodified-
749 Since and the two are only combined for the sake of interoperating
750 with older intermediaries that might not implement If-Match.
752 A recipient MUST ignore the If-Unmodified-Since header field if the
753 received field-value is not a valid HTTP-date.
755 A recipient MUST interpret an If-Unmodified-Since field-value's
756 timestamp in terms of the origin server's clock.
758 If-Unmodified-Since is most often used with state-changing methods
759 (e.g., POST, PUT, DELETE) to prevent accidental overwrites when
760 multiple user agents might be acting in parallel on a resource that
761 does not supply entity-tags with its representations (i.e., to
762 prevent the "lost update" problem). It can also be used with safe
763 methods to abort a request if the selected representation does not
764 match one already stored (or partially stored) from a prior request.
766 An origin server that receives an If-Unmodified-Since header field
767 MUST evaluate the condition prior to performing the method
768 (Section 5). The origin server MUST NOT perform the requested method
769 if the selected representation's last modification date is more
770 recent than the date provided in the field-value; instead the origin
771 server MUST respond with either: a) the 412 (Precondition Failed)
772 status code; or, b) one of the 2xx (Successful) status codes if the
773 origin server has verified that a state change is being requested and
774 the final state is already reflected in the current state of the
775 target resource (i.e., the change requested by the user agent has
776 already succeeded, but the user agent might not be aware of that
777 because the prior response message was lost or a compatible change
778 was made by some other user agent). In the latter case, the origin
779 server MUST NOT send a validator header field in the response unless
780 it can verify that the request is a duplicate of an immediately prior
781 change made by the same user agent.
783 The If-Unmodified-Since header field can be ignored by caches and
784 intermediaries because it is not applicable to a stored response.
786 3.5. If-Range
788 The "If-Range" header field provides a special conditional request
789 mechanism that is similar to the If-Match and If-Unmodified-Since
790 header fields but instructs the recipient to ignore the Range header
791 field if the validator doesn't match, resulting in transfer of the
792 new selected representation instead of a 412 response. If-Range is
793 defined in Section 3.2 of [Part5].
795 4. Status Code Definitions
797 4.1. 304 Not Modified
799 The 304 (Not Modified) status code indicates that a conditional GET
800 or HEAD request has been received and would have resulted in a 200
801 (OK) response if it were not for the fact that the condition has
802 evaluated to false. In other words, there is no need for the server
803 to transfer a representation of the target resource because the
804 request indicates that the client, which made the request
805 conditional, already has a valid representation; the server is
806 therefore redirecting the client to make use of that stored
807 representation as if it were the payload of a 200 (OK) response.
809 The server generating a 304 response MUST generate any of the
810 following header fields that would have been sent in a 200 (OK)
811 response to the same request: Cache-Control, Content-Location, Date,
812 ETag, Expires, and Vary.
814 Since the goal of a 304 response is to minimize information transfer
815 when the recipient already has one or more cached representations, a
816 sender SHOULD NOT generate representation metadata other than the
817 above listed fields unless said metadata exists for the purpose of
818 guiding cache updates (e.g., Last-Modified might be useful if the
819 response does not have an ETag field).
821 Requirements on a cache that receives a 304 response are defined in
822 Section 4.3.4 of [Part6]. If the conditional request originated with
823 an outbound client, such as a user agent with its own cache sending a
824 conditional GET to a shared proxy, then the proxy SHOULD forward the
825 304 response to that client.
827 A 304 response cannot contain a message-body; it is always terminated
828 by the first empty line after the header fields.
830 4.2. 412 Precondition Failed
832 The 412 (Precondition Failed) status code indicates that one or more
833 conditions given in the request header fields evaluated to false when
834 tested on the server. This response code allows the client to place
835 preconditions on the current resource state (its current
836 representations and metadata) and thus prevent the request method
837 from being applied if the target resource is in an unexpected state.
839 5. Evaluation
841 Except when excluded below, a recipient cache or origin server MUST
842 evaluate received request preconditions after it has successfully
843 performed its normal request checks and just before it would perform
844 the action associated with the request method. A server MUST ignore
845 all received preconditions if its response to the same request
846 without those conditions would have been a status code other than a
847 2xx or 412 (Precondition Failed). In other words, redirects and
848 failures take precedence over the evaluation of preconditions in
849 conditional requests.
851 A server that is not the origin server for the target resource and
852 cannot act as a cache for requests on the target resource MUST NOT
853 evaluate the conditional request header fields defined by this
854 specification, and MUST forward them if the request is forwarded,
855 since the generating client intends that they be evaluated by a
856 server that can provide a current representation. Likewise, a server
857 MUST ignore the conditional request header fields defined by this
858 specification when received with a request method that does not
859 involve the selection or modification of a selected representation,
860 such as CONNECT, OPTIONS, or TRACE.
862 Conditional request header fields that are defined by extensions to
863 HTTP might place conditions on all recipients, on the state of the
864 target resource in general, or on a group of resources. For
865 instance, the "If" header field in WebDAV can make a request
866 conditional on various aspects of multiple resources, such as locks,
867 if the recipient understands and implements that field ([RFC4918],
868 Section 10.4).
870 Although conditional request header fields are defined as being
871 usable with the HEAD method (to keep HEAD's semantics consistent with
872 those of GET), there is no point in sending a conditional HEAD
873 because a successful response is around the same size as a 304 (Not
874 Modified) response and more useful than a 412 (Precondition Failed)
875 response.
877 6. Precedence
879 When more than one conditional request header field is present in a
880 request, the order in which the fields are evaluated becomes
881 important. In practice, the fields defined in this document are
882 consistently implemented in a single, logical order, since "lost
883 update" preconditions have more strict requirements than cache
884 validation, a validated cache is more efficient than a partial
885 response, and entity tags are presumed to be more accurate than date
886 validators.
888 A recipient cache or origin server MUST evaluate the request
889 preconditions defined by this specification in the following order:
891 1. When recipient is the origin server and If-Match is present,
892 evaluate the If-Match precondition:
894 * if true, continue to step 3
896 * if false, respond 412 (Precondition Failed) unless it can be
897 determined that the state-changing request has already
898 succeeded (see Section 3.1)
900 2. When recipient is the origin server, If-Match is not present, and
901 If-Unmodified-Since is present, evaluate the If-Unmodified-Since
902 precondition:
904 * if true, continue to step 3
906 * if false, respond 412 (Precondition Failed) unless it can be
907 determined that the state-changing request has already
908 succeeded (see Section 3.4)
910 3. When If-None-Match is present, evaluate the If-None-Match
911 precondition:
913 * if true, continue to step 5
915 * if false for GET/HEAD, respond 304 (Not Modified)
917 * if false for other methods, respond 412 (Precondition Failed)
919 4. When the method is GET or HEAD, If-None-Match is not present, and
920 If-Modified-Since is present, evaluate the If-Modified-Since
921 precondition:
923 * if true, continue to step 5
925 * if false, respond 304 (Not Modified)
927 5. When the method is GET and both Range and If-Range are present,
928 evaluate the If-Range precondition:
930 * if the validator matches and the Range specification is
931 applicable to the selected representation, respond 206
932 (Partial Content) [Part5]
934 6. Otherwise,
936 * all conditions are met, so perform the requested action and
937 respond according to its success or failure.
939 Any extension to HTTP/1.1 that defines additional conditional request
940 header fields ought to define its own expectations regarding the
941 order for evaluating such fields in relation to those defined in this
942 document and other conditionals that might be found in practice.
944 7. IANA Considerations
946 7.1. Status Code Registration
948 The HTTP Status Code Registry located at
949 shall be updated
950 with the registrations below:
952 +-------+---------------------+-------------+
953 | Value | Description | Reference |
954 +-------+---------------------+-------------+
955 | 304 | Not Modified | Section 4.1 |
956 | 412 | Precondition Failed | Section 4.2 |
957 +-------+---------------------+-------------+
959 7.2. Header Field Registration
961 HTTP header fields are registered within the Message Header Field
962 Registry maintained at .
965 This document defines the following HTTP header fields, so their
966 associated registry entries shall be updated according to the
967 permanent registrations below (see [BCP90]):
969 +---------------------+----------+----------+-------------+
970 | Header Field Name | Protocol | Status | Reference |
971 +---------------------+----------+----------+-------------+
972 | ETag | http | standard | Section 2.3 |
973 | If-Match | http | standard | Section 3.1 |
974 | If-Modified-Since | http | standard | Section 3.3 |
975 | If-None-Match | http | standard | Section 3.2 |
976 | If-Unmodified-Since | http | standard | Section 3.4 |
977 | Last-Modified | http | standard | Section 2.2 |
978 +---------------------+----------+----------+-------------+
980 The change controller is: "IETF (iesg@ietf.org) - Internet
981 Engineering Task Force".
983 8. Security Considerations
985 This section is meant to inform developers, information providers,
986 and users of known security concerns specific to the HTTP/1.1
987 conditional request mechanisms. More general security considerations
988 are addressed in HTTP messaging [Part1] and semantics [Part2].
990 The validators defined by this specification are not intended to
991 ensure the validity of a representation, guard against malicious
992 changes, or detect man-in-the-middle attacks. At best, they enable
993 more efficient cache updates and optimistic concurrent writes when
994 all participants are behaving nicely. At worst, the conditions will
995 fail and the client will receive a response that is no more harmful
996 than an HTTP exchange without conditional requests.
998 An entity-tag can be abused in ways that create privacy risks. For
999 example, a site might deliberately construct a semantically invalid
1000 entity-tag that is unique to the user or user agent, send it in a
1001 cacheable response with a long freshness time, and then read that
1002 entity-tag in later conditional requests as a means of re-identifying
1003 that user or user agent. Such an identifying tag would become a
1004 persistent identifier for as long as the user agent retained the
1005 original cache entry. User agents that cache representations ought
1006 to ensure that the cache is cleared or replaced whenever the user
1007 performs privacy-maintaining actions, such as clearing stored cookies
1008 or changing to a private browsing mode.
1010 9. Acknowledgments
1012 See Section 10 of [Part1].
1014 10. References
1015 10.1. Normative References
1017 [Part1] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
1018 Protocol (HTTP/1.1): Message Syntax and Routing",
1019 draft-ietf-httpbis-p1-messaging-25 (work in progress),
1020 November 2013.
1022 [Part2] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
1023 Protocol (HTTP/1.1): Semantics and Content",
1024 draft-ietf-httpbis-p2-semantics-25 (work in progress),
1025 November 2013.
1027 [Part5] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed.,
1028 "Hypertext Transfer Protocol (HTTP/1.1): Range Requests",
1029 draft-ietf-httpbis-p5-range-25 (work in progress),
1030 November 2013.
1032 [Part6] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
1033 Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching",
1034 draft-ietf-httpbis-p6-cache-25 (work in progress),
1035 November 2013.
1037 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
1038 Requirement Levels", BCP 14, RFC 2119, March 1997.
1040 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
1041 Specifications: ABNF", STD 68, RFC 5234, January 2008.
1043 10.2. Informative References
1045 [BCP90] Klyne, G., Nottingham, M., and J. Mogul, "Registration
1046 Procedures for Message Header Fields", BCP 90, RFC 3864,
1047 September 2004.
1049 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
1050 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
1051 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
1053 [RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed
1054 Authoring and Versioning (WebDAV)", RFC 4918, June 2007.
1056 Appendix A. Changes from RFC 2616
1058 The definition of validator weakness has been expanded and clarified.
1059 (Section 2.1)
1061 Weak entity-tags are now allowed in all requests except range
1062 requests. (Sections 2.1 and 3.2)
1063 The ETag header field ABNF has been changed to not use quoted-string,
1064 thus avoiding escaping issues. (Section 2.3)
1066 ETag is defined to provide an entity tag for the selected
1067 representation, thereby clarifying what it applies to in various
1068 situations (such as a PUT response). (Section 2.3)
1070 The precedence for evaluation of conditional requests has been
1071 defined. (Section 6)
1073 Appendix B. Imported ABNF
1075 The following core rules are included by reference, as defined in
1076 Appendix B.1 of [RFC5234]: ALPHA (letters), CR (carriage return),
1077 CRLF (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double
1078 quote), HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed), OCTET (any
1079 8-bit sequence of data), SP (space), and VCHAR (any visible US-ASCII
1080 character).
1082 The rules below are defined in [Part1]:
1084 OWS =
1085 obs-text =
1087 The rules below are defined in other parts:
1089 HTTP-date =
1091 Appendix C. Collected ABNF
1093 In the collected ABNF below, list rules are expanded as per Section
1094 1.2 of [Part1].
1096 ETag = entity-tag
1098 HTTP-date =
1100 If-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
1101 entity-tag ] ) )
1102 If-Modified-Since = HTTP-date
1103 If-None-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
1104 entity-tag ] ) )
1105 If-Unmodified-Since = HTTP-date
1107 Last-Modified = HTTP-date
1109 OWS =
1111 entity-tag = [ weak ] opaque-tag
1112 etagc = "!" / %x23-7E ; '#'-'~'
1113 / obs-text
1115 obs-text =
1116 opaque-tag = DQUOTE *etagc DQUOTE
1118 weak = %x57.2F ; W/
1120 Appendix D. Change Log (to be removed by RFC Editor before publication)
1122 Changes up to the IETF Last Call draft are summarized in .
1125 D.1. Since draft-ietf-httpbis-p4-conditional-24
1127 Closed issues:
1129 o : "APPSDIR
1130 review of draft-ietf-httpbis-p4-conditional-24"
1132 Index
1134 3
1135 304 Not Modified (status code) 18
1137 4
1138 412 Precondition Failed (status code) 18
1140 E
1141 ETag header field 9
1143 G
1144 Grammar
1145 entity-tag 9
1146 ETag 9
1147 etagc 9
1148 If-Match 13
1149 If-Modified-Since 15
1150 If-None-Match 14
1151 If-Unmodified-Since 16
1152 Last-Modified 7
1153 opaque-tag 9
1154 weak 9
1156 I
1157 If-Match header field 13
1158 If-Modified-Since header field 15
1159 If-None-Match header field 14
1160 If-Unmodified-Since header field 16
1162 L
1163 Last-Modified header field 7
1165 M
1166 metadata 5
1168 S
1169 selected representation 4
1171 V
1172 validator 5
1173 strong 5
1174 weak 5
1176 Authors' Addresses
1178 Roy T. Fielding (editor)
1179 Adobe Systems Incorporated
1180 345 Park Ave
1181 San Jose, CA 95110
1182 USA
1184 EMail: fielding@gbiv.com
1185 URI: http://roy.gbiv.com/
1186 Julian F. Reschke (editor)
1187 greenbytes GmbH
1188 Hafenweg 16
1189 Muenster, NW 48155
1190 Germany
1192 EMail: julian.reschke@greenbytes.de
1193 URI: http://greenbytes.de/tech/webdav/