idnits 2.17.1
draft-ietf-httpbis-p4-conditional-23.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 (July 15, 2013) is 3938 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-23
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p2-semantics-23
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p5-range-23
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p6-cache-23
-- 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: January 16, 2014 July 15, 2013
8 Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests
9 draft-ietf-httpbis-p4-conditional-23
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.4.
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 January 16, 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 . . . . . . . . . . . . . . . . . . . . . . 10
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 . . . . . . . . . . . . . . . . . . . . . . . . . 16
99 4. Status Code Definitions . . . . . . . . . . . . . . . . . . . 17
100 4.1. 304 Not Modified . . . . . . . . . . . . . . . . . . . . . 17
101 4.2. 412 Precondition Failed . . . . . . . . . . . . . . . . . 17
102 5. Evaluation and Precedence . . . . . . . . . . . . . . . . . . 17
103 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 20
104 6.1. Status Code Registration . . . . . . . . . . . . . . . . . 20
105 6.2. Header Field Registration . . . . . . . . . . . . . . . . 20
106 7. Security Considerations . . . . . . . . . . . . . . . . . . . 20
107 8. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 21
108 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 21
109 9.1. Normative References . . . . . . . . . . . . . . . . . . . 21
110 9.2. Informative References . . . . . . . . . . . . . . . . . . 22
111 Appendix A. Changes from RFC 2616 . . . . . . . . . . . . . . . . 22
112 Appendix B. Imported ABNF . . . . . . . . . . . . . . . . . . . . 22
113 Appendix C. Collected ABNF . . . . . . . . . . . . . . . . . . . 23
114 Appendix D. Change Log (to be removed by RFC Editor before
115 publication) . . . . . . . . . . . . . . . . . . . . 23
116 D.1. Since draft-ietf-httpbis-p4-conditional-19 . . . . . . . . 23
117 D.2. Since draft-ietf-httpbis-p4-conditional-20 . . . . . . . . 24
118 D.3. Since draft-ietf-httpbis-p4-conditional-21 . . . . . . . . 24
119 D.4. Since draft-ietf-httpbis-p4-conditional-22 . . . . . . . . 25
120 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
122 1. Introduction
124 Conditional requests are HTTP requests [Part2] that include one or
125 more header fields indicating a precondition to be tested before
126 applying the method semantics to the target resource. This document
127 defines the HTTP/1.1 conditional request mechanisms in terms of the
128 architecture, syntax notation, and conformance criteria defined in
129 [Part1].
131 Conditional GET requests are the most efficient mechanism for HTTP
132 cache updates [Part6]. Conditionals can also be applied to state-
133 changing methods, such as PUT and DELETE, to prevent the "lost
134 update" problem: one client accidentally overwriting the work of
135 another client that has been acting in parallel.
137 Conditional request preconditions are based on the state of the
138 target resource as a whole (its current value set) or the state as
139 observed in a previously obtained representation (one value in that
140 set). A resource might have multiple current representations, each
141 with its own observable state. The conditional request mechanisms
142 assume that the mapping of requests to a "selected representation"
143 (Section 3 of [Part2]) will be consistent over time if the server
144 intends to take advantage of conditionals. Regardless, if the
145 mapping is inconsistent and the server is unable to select the
146 appropriate representation, then no harm will result when the
147 precondition evaluates to false.
149 The conditional request preconditions defined by this specification
150 are evaluated by comparing the validators provided in the conditional
151 request header fields to the current validators for the selected
152 representation in the order defined by Section 5.
154 1.1. Conformance and Error Handling
156 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
157 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
158 document are to be interpreted as described in [RFC2119].
160 Conformance criteria and considerations regarding error handling are
161 defined in Section 2.5 of [Part1].
163 1.2. Syntax Notation
165 This specification uses the Augmented Backus-Naur Form (ABNF)
166 notation of [RFC5234] with the list rule extension defined in Section
167 1.2 of [Part1]. Appendix B describes rules imported from other
168 documents. Appendix C shows the collected ABNF with the list rule
169 expanded.
171 2. Validators
173 This specification defines two forms of metadata that are commonly
174 used to observe resource state and test for preconditions:
175 modification dates (Section 2.2) and opaque entity tags
176 (Section 2.3). Additional metadata that reflects resource state has
177 been defined by various extensions of HTTP, such as WebDAV [RFC4918],
178 that are beyond the scope of this specification. A resource metadata
179 value is referred to as a "validator" when it is used within a
180 precondition.
182 2.1. Weak versus Strong
184 Validators come in two flavors: strong or weak. Weak validators are
185 easy to generate but are far less useful for comparisons. Strong
186 validators are ideal for comparisons but can be very difficult (and
187 occasionally impossible) to generate efficiently. Rather than impose
188 that all forms of resource adhere to the same strength of validator,
189 HTTP exposes the type of validator in use and imposes restrictions on
190 when weak validators can be used as preconditions.
192 A "strong validator" is representation metadata that changes value
193 whenever a change occurs to the representation data that would be
194 observable in the payload body of a 200 (OK) response to GET.
196 A strong validator might change for other reasons, such as when a
197 semantically significant part of the representation metadata is
198 changed (e.g., Content-Type), but it is in the best interests of the
199 origin server to only change the value when it is necessary to
200 invalidate the stored responses held by remote caches and authoring
201 tools. A strong validator is unique across all representations of a
202 given resource, such that no two representations of that resource can
203 share the same validator unless their representation data is
204 identical.
206 Cache entries might persist for arbitrarily long periods, regardless
207 of expiration times. Thus, a cache might attempt to validate an
208 entry using a validator that it obtained in the distant past. A
209 strong validator is unique across all versions of all representations
210 associated with a particular resource over time. However, there is
211 no implication of uniqueness across representations of different
212 resources (i.e., the same strong validator might be in use for
213 representations of multiple resources at the same time and does not
214 imply that those representations are equivalent).
216 There are a variety of strong validators used in practice. The best
217 are based on strict revision control, wherein each change to a
218 representation always results in a unique node name and revision
219 identifier being assigned before the representation is made
220 accessible to GET. A collision-resistant hash function applied to
221 the representation data is also sufficient if the data is available
222 prior to the response header fields being sent and the digest does
223 not need to be recalculated every time a validation request is
224 received. However, if a resource has distinct representations that
225 differ only in their metadata, such as might occur with content
226 negotiation over media types that happen to share the same data
227 format, then the origin server SHOULD incorporate additional
228 information in the validator to distinguish those representations.
230 In contrast, a "weak validator" is representation metadata that might
231 not change for every change to the representation data. This
232 weakness might be due to limitations in how the value is calculated,
233 such as clock resolution or an inability to ensure uniqueness for all
234 possible representations of the resource, or due to a desire by the
235 resource owner to group representations by some self-determined set
236 of equivalency rather than unique sequences of data. An origin
237 server SHOULD change a weak entity-tag whenever it considers prior
238 representations to be unacceptable as a substitute for the current
239 representation. In other words, a weak entity-tag ought to change
240 whenever the origin server wants caches to invalidate old responses.
242 For example, the representation of a weather report that changes in
243 content every second, based on dynamic measurements, might be grouped
244 into sets of equivalent representations (from the origin server's
245 perspective) with the same weak validator in order to allow cached
246 representations to be valid for a reasonable period of time (perhaps
247 adjusted dynamically based on server load or weather quality).
248 Likewise, a representation's modification time, if defined with only
249 one-second resolution, might be a weak validator if it is possible
250 for the representation to be modified twice during a single second
251 and retrieved between those modifications.
253 Likewise, a validator is weak if it is shared by two or more
254 representations of a given resource at the same time, unless those
255 representations have identical representation data. For example, if
256 the origin server sends the same validator for a representation with
257 a gzip content coding applied as it does for a representation with no
258 content coding, then that validator is weak. However, two
259 simultaneous representations might share the same strong validator if
260 they differ only in the representation metadata, such as when two
261 different media types are available for the same representation data.
263 A "use" of a validator occurs when either a client generates a
264 request and includes the validator in a precondition or when a server
265 compares two validators. Weak validators are only usable in contexts
266 that do not depend on exact equality of the representation data.
268 Strong validators are usable and preferred for all conditional
269 requests, including cache validation, partial content ranges, and
270 "lost update" avoidance.
272 2.2. Last-Modified
274 The "Last-Modified" header field in a response provides a timestamp
275 indicating the date and time at which the origin server believes the
276 selected representation was last modified, as determined at the
277 conclusion of handling the request.
279 Last-Modified = HTTP-date
281 An example of its use is
283 Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
285 2.2.1. Generation
287 Origin servers SHOULD send Last-Modified for any selected
288 representation for which a last modification date can be reasonably
289 and consistently determined, since its use in conditional requests
290 and evaluating cache freshness ([Part6]) results in a substantial
291 reduction of HTTP traffic on the Internet and can be a significant
292 factor in improving service scalability and reliability.
294 A representation is typically the sum of many parts behind the
295 resource interface. The last-modified time would usually be the most
296 recent time that any of those parts were changed. How that value is
297 determined for any given resource is an implementation detail beyond
298 the scope of this specification. What matters to HTTP is how
299 recipients of the Last-Modified header field can use its value to
300 make conditional requests and test the validity of locally cached
301 responses.
303 An origin server SHOULD obtain the Last-Modified value of the
304 representation as close as possible to the time that it generates the
305 Date field value for its response. This allows a recipient to make
306 an accurate assessment of the representation's modification time,
307 especially if the representation changes near the time that the
308 response is generated.
310 An origin server with a clock MUST NOT send a Last-Modified date that
311 is later than the server's time of message origination (Date). If
312 the last modification time is derived from implementation-specific
313 metadata that evaluates to some time in the future, according to the
314 origin server's clock, then the origin server MUST replace that value
315 with the message origination date. This prevents a future
316 modification date from having an adverse impact on cache validation.
318 An origin server without a clock MUST NOT assign Last-Modified values
319 to a response unless these values were associated with the resource
320 by some other system or user with a reliable clock.
322 2.2.2. Comparison
324 A Last-Modified time, when used as a validator in a request, is
325 implicitly weak unless it is possible to deduce that it is strong,
326 using the following rules:
328 o The validator is being compared by an origin server to the actual
329 current validator for the representation and,
331 o That origin server reliably knows that the associated
332 representation did not change twice during the second covered by
333 the presented validator.
335 or
337 o The validator is about to be used by a client in an If-Modified-
338 Since, If-Unmodified-Since header field, because the client has a
339 cache entry, or If-Range for the associated representation, and
341 o That cache entry includes a Date value, which gives the time when
342 the origin server sent the original response, and
344 o The presented Last-Modified time is at least 60 seconds before the
345 Date value.
347 or
349 o The validator is being compared by an intermediate cache to the
350 validator stored in its cache entry for the representation, and
352 o That cache entry includes a Date value, which gives the time when
353 the origin server sent the original response, and
355 o The presented Last-Modified time is at least 60 seconds before the
356 Date value.
358 This method relies on the fact that if two different responses were
359 sent by the origin server during the same second, but both had the
360 same Last-Modified time, then at least one of those responses would
361 have a Date value equal to its Last-Modified time. The arbitrary 60-
362 second limit guards against the possibility that the Date and Last-
363 Modified values are generated from different clocks, or at somewhat
364 different times during the preparation of the response. An
365 implementation MAY use a value larger than 60 seconds, if it is
366 believed that 60 seconds is too short.
368 2.3. ETag
370 The "ETag" header field in a response provides the current entity-tag
371 for the selected representation, as determined at the conclusion of
372 handling the request. An entity-tag is an opaque validator for
373 differentiating between multiple representations of the same
374 resource, regardless of whether those multiple representations are
375 due to resource state changes over time, content negotiation
376 resulting in multiple representations being valid at the same time,
377 or both. An entity-tag consists of an opaque quoted string, possibly
378 prefixed by a weakness indicator.
380 ETag = entity-tag
382 entity-tag = [ weak ] opaque-tag
383 weak = %x57.2F ; "W/", case-sensitive
384 opaque-tag = DQUOTE *etagc DQUOTE
385 etagc = %x21 / %x23-7E / obs-text
386 ; VCHAR except double quotes, plus obs-text
388 Note: Previously, opaque-tag was defined to be a quoted-string
389 ([RFC2616], Section 3.11), thus some recipients might perform
390 backslash unescaping. Servers therefore ought to avoid backslash
391 characters in entity tags.
393 An entity-tag can be more reliable for validation than a modification
394 date in situations where it is inconvenient to store modification
395 dates, where the one-second resolution of HTTP date values is not
396 sufficient, or where modification dates are not consistently
397 maintained.
399 Examples:
401 ETag: "xyzzy"
402 ETag: W/"xyzzy"
403 ETag: ""
405 An entity-tag can be either a weak or strong validator, with strong
406 being the default. If an origin server provides an entity-tag for a
407 representation and the generation of that entity-tag does not satisfy
408 all of the characteristics of a strong validator (Section 2.1), then
409 the origin server MUST mark the entity-tag as weak by prefixing its
410 opaque value with "W/" (case-sensitive).
412 2.3.1. Generation
414 The principle behind entity-tags is that only the service author
415 knows the implementation of a resource well enough to select the most
416 accurate and efficient validation mechanism for that resource, and
417 that any such mechanism can be mapped to a simple sequence of octets
418 for easy comparison. Since the value is opaque, there is no need for
419 the client to be aware of how each entity-tag is constructed.
421 For example, a resource that has implementation-specific versioning
422 applied to all changes might use an internal revision number, perhaps
423 combined with a variance identifier for content negotiation, to
424 accurately differentiate between representations. Other
425 implementations might use a collision-resistant hash of
426 representation content, a combination of various filesystem
427 attributes, or a modification timestamp that has sub-second
428 resolution.
430 Origin servers SHOULD send ETag for any selected representation for
431 which detection of changes can be reasonably and consistently
432 determined, since the entity-tag's use in conditional requests and
433 evaluating cache freshness ([Part6]) can result in a substantial
434 reduction of HTTP network traffic and can be a significant factor in
435 improving service scalability and reliability.
437 2.3.2. Comparison
439 There are two entity-tag comparison functions, depending on whether
440 the comparison context allows the use of weak validators or not:
442 o Strong comparison: two entity-tags are equivalent if both are not
443 weak and their opaque-tags match character-by-character.
445 o Weak comparison: two entity-tags are equivalent if their opaque-
446 tags match character-by-character, regardless of either or both
447 being tagged as "weak".
449 The example below shows the results for a set of entity-tag pairs,
450 and both the weak and strong comparison function results:
452 +--------+--------+-------------------+-----------------+
453 | ETag 1 | ETag 2 | Strong Comparison | Weak Comparison |
454 +--------+--------+-------------------+-----------------+
455 | W/"1" | W/"1" | no match | match |
456 | W/"1" | W/"2" | no match | no match |
457 | W/"1" | "1" | no match | match |
458 | "1" | "1" | match | match |
459 +--------+--------+-------------------+-----------------+
461 2.3.3. Example: Entity-tags Varying on Content-Negotiated Resources
463 Consider a resource that is subject to content negotiation (Section
464 3.4 of [Part2]), and where the representations sent in response to a
465 GET request vary based on the Accept-Encoding request header field
466 (Section 5.3.4 of [Part2]):
468 >> Request:
470 GET /index HTTP/1.1
471 Host: www.example.com
472 Accept-Encoding: gzip
474 In this case, the response might or might not use the gzip content
475 coding. If it does not, the response might look like:
477 >> Response:
479 HTTP/1.1 200 OK
480 Date: Fri, 26 Mar 2010 00:05:00 GMT
481 ETag: "123-a"
482 Content-Length: 70
483 Vary: Accept-Encoding
484 Content-Type: text/plain
486 Hello World!
487 Hello World!
488 Hello World!
489 Hello World!
490 Hello World!
492 An alternative representation that does use gzip content coding would
493 be:
495 >> Response:
497 HTTP/1.1 200 OK
498 Date: Fri, 26 Mar 2010 00:05:00 GMT
499 ETag: "123-b"
500 Content-Length: 43
501 Vary: Accept-Encoding
502 Content-Type: text/plain
503 Content-Encoding: gzip
505 ...binary data...
507 Note: Content codings are a property of the representation, so
508 therefore an entity-tag of an encoded representation has to be
509 distinct from an unencoded representation to prevent conflicts
510 during cache updates and range requests. In contrast, transfer
511 codings (Section 4 of [Part1]) apply only during message transfer
512 and do not require distinct entity-tags.
514 2.4. When to Use Entity-tags and Last-Modified Dates
516 We adopt a set of rules and recommendations for origin servers,
517 clients, and caches regarding when various validator types ought to
518 be used, and for what purposes.
520 In 200 (OK) responses to GET or HEAD, an origin server:
522 o SHOULD send an entity-tag validator unless it is not feasible to
523 generate one.
525 o MAY send a weak entity-tag instead of a strong entity-tag, if
526 performance considerations support the use of weak entity-tags, or
527 if it is unfeasible to send a strong entity-tag.
529 o SHOULD send a Last-Modified value if it is feasible to send one.
531 In other words, the preferred behavior for an origin server is to
532 send both a strong entity-tag and a Last-Modified value in successful
533 responses to a retrieval request.
535 A client:
537 o MUST use that entity-tag in any cache-conditional request (using
538 If-Match or If-None-Match) if an entity-tag has been provided by
539 the origin server.
541 o SHOULD use the Last-Modified value in non-subrange cache-
542 conditional requests (using If-Modified-Since) if only a Last-
543 Modified value has been provided by the origin server.
545 o MAY use the Last-Modified value in subrange cache-conditional
546 requests (using If-Unmodified-Since) if only a Last-Modified value
547 has been provided by an HTTP/1.0 origin server. The user agent
548 SHOULD provide a way to disable this, in case of difficulty.
550 o SHOULD use both validators in cache-conditional requests if both
551 an entity-tag and a Last-Modified value have been provided by the
552 origin server. This allows both HTTP/1.0 and HTTP/1.1 caches to
553 respond appropriately.
555 3. Precondition Header Fields
557 This section defines the syntax and semantics of HTTP/1.1 header
558 fields for applying preconditions on requests. Section 5 defines
559 when the preconditions are applied and the order of evaluation when
560 more than one precondition is present.
562 3.1. If-Match
564 The "If-Match" header field can be used to make a request method
565 conditional on the current existence or value of an entity-tag for
566 one or more representations of the target resource.
568 If-Match is generally useful for resource update requests, such as
569 PUT requests, as a means for protecting against accidental overwrites
570 when multiple clients are acting in parallel on the same resource
571 (i.e., the "lost update" problem). An If-Match field-value of "*"
572 places the precondition on the existence of any current
573 representation for the target resource.
575 If-Match = "*" / 1#entity-tag
577 The If-Match condition is met if and only if any of the entity-tags
578 listed in the If-Match field value match the entity-tag of the
579 selected representation using the weak comparison function (as per
580 Section 2.3.2), or if "*" is given and any current representation
581 exists for the target resource.
583 If the condition is met, the server MAY perform the request method.
585 Origin servers MUST NOT perform the requested method if the condition
586 is not met; instead they MUST respond with the 412 (Precondition
587 Failed) status code.
589 Proxy servers using a cached response as the selected representation
590 MUST NOT perform the requested method if the condition is not met;
591 instead, they MUST forward the request towards the origin server.
593 Examples:
595 If-Match: "xyzzy"
596 If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
597 If-Match: *
599 3.2. If-None-Match
601 The "If-None-Match" header field can be used to make a request method
602 conditional on not matching any of the current entity-tag values for
603 representations of the target resource.
605 If-None-Match is primarily used in conditional GET requests to enable
606 efficient updates of cached information with a minimum amount of
607 transaction overhead. A client that has one or more representations
608 previously obtained from the target resource can send If-None-Match
609 with a list of the associated entity-tags in the hope of receiving a
610 304 (Not Modified) response if at least one of those representations
611 matches the selected representation.
613 If-None-Match can also be used with a value of "*" to prevent an
614 unsafe request method (e.g., PUT) from inadvertently modifying an
615 existing representation of the target resource when the client
616 believes that the resource does not have a current representation
617 (Section 4.2.1 of [Part2]). This is a variation on the "lost update"
618 problem that might arise if more than one client attempts to create
619 an initial representation for the target resource.
621 If-None-Match = "*" / 1#entity-tag
623 The If-None-Match condition is met if and only if none of the entity-
624 tags listed in the If-None-Match field value match the entity-tag of
625 the selected representation using the weak comparison function (as
626 per Section 2.3.2), or if "*" is given and no current representation
627 exists for that resource.
629 If the condition is not met, the server MUST NOT perform the
630 requested method. Instead, if the request method was GET or HEAD,
631 the server SHOULD respond with a 304 (Not Modified) status code,
632 including the cache-related header fields (particularly ETag) of the
633 selected representation that has a matching entity-tag. For all
634 other request methods, the server MUST respond with a 412
635 (Precondition Failed) status code when the condition is not met.
637 If the condition is met, the server MAY perform the requested method
638 and MUST ignore any If-Modified-Since header field(s) in the request.
639 That is, if no entity-tags match, then the server MUST NOT send a 304
640 (Not Modified) response.
642 Examples:
644 If-None-Match: "xyzzy"
645 If-None-Match: W/"xyzzy"
646 If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
647 If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"
648 If-None-Match: *
650 3.3. If-Modified-Since
652 The "If-Modified-Since" header field can be used with GET or HEAD to
653 make the method conditional by modification date: if the selected
654 representation has not been modified since the time specified in this
655 field, then do not perform the request method; instead, respond as
656 detailed below.
658 If-Modified-Since = HTTP-date
660 An example of the field is:
662 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
664 A GET method with an If-Modified-Since header field and no Range
665 header field requests that the selected representation be transferred
666 only if it has been modified since the date given by the If-Modified-
667 Since header field. The algorithm for determining this includes the
668 following cases:
670 1. If the request would normally result in anything other than a 200
671 (OK) status code, or if the passed If-Modified-Since date is
672 invalid, the response is exactly the same as for a normal GET. A
673 date that is later than the server's current time is invalid.
675 2. If the selected representation has been modified since the If-
676 Modified-Since date, the response is exactly the same as for a
677 normal GET.
679 3. If the selected representation has not been modified since a
680 valid If-Modified-Since date, the server SHOULD send a 304 (Not
681 Modified) response.
683 The two purposes of this feature are to allow efficient updates of
684 cached information, with a minimum amount of transaction overhead,
685 and to limit the scope of a web traversal to resources that have
686 recently changed.
688 When used for cache updates, a cache will typically use the value of
689 the cached message's Last-Modified field to generate the field value
690 of If-Modified-Since. This behavior is most interoperable for cases
691 where clocks are poorly synchronized or when the server has chosen to
692 only honor exact timestamp matches (due to a problem with Last-
693 Modified dates that appear to go "back in time" when the origin
694 server's clock is corrected or a representation is restored from an
695 archived backup). However, caches occasionally generate the field
696 value based on other data, such as the Date header field of the
697 cached message or the local clock time that the message was received,
698 particularly when the cached message does not contain a Last-Modified
699 field.
701 When used for limiting the scope of retrieval to a recent time
702 window, a user agent will generate an If-Modified-Since field value
703 based on either its own local clock or a Date header field received
704 from the server during a past run. Origin servers that choose an
705 exact timestamp match based on the selected representation's Last-
706 Modified field will not be able to help the user agent limit its data
707 transfers to only those changed during the specified window.
709 Note: If a client uses an arbitrary date in the If-Modified-Since
710 header field instead of a date taken from a Last-Modified or Date
711 header field from the origin server, the client ought to be aware
712 that its date will be interpreted according to the server's
713 understanding of time.
715 3.4. If-Unmodified-Since
717 The "If-Unmodified-Since" header field can be used to make a request
718 method conditional by modification date: if the selected
719 representation has been modified since the time specified in this
720 field, then the server MUST NOT perform the requested operation and
721 MUST instead respond with the 412 (Precondition Failed) status code.
722 If the selected representation has not been modified since the time
723 specified in this field, the server MAY perform the request.
725 If-Unmodified-Since = HTTP-date
727 An example of the field is:
729 If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
731 A server MUST ignore the If-Unmodified-Since header field if the
732 received value is not a valid HTTP-date.
734 3.5. If-Range
736 The "If-Range" header field provides a special conditional request
737 mechanism that is similar to If-Match and If-Unmodified-Since but
738 specific to range requests. If-Range is defined in Section 3.2 of
739 [Part5].
741 4. Status Code Definitions
743 4.1. 304 Not Modified
745 The 304 (Not Modified) status code indicates that a conditional GET
746 or HEAD request has been received and would have resulted in a 200
747 (OK) response if it were not for the fact that the condition has
748 evaluated to false. In other words, there is no need for the server
749 to transfer a representation of the target resource because the
750 request indicates that the client, which made the request
751 conditional, already has a valid representation; the server is
752 therefore redirecting the client to make use of that stored
753 representation as if it were the payload of a 200 (OK) response.
755 The server generating a 304 response MUST generate any of the
756 following header fields that would have been sent in a 200 (OK)
757 response to the same request: Cache-Control, Content-Location, ETag,
758 Expires, and Vary.
760 Since the goal of a 304 response is to minimize information transfer
761 when the recipient already has one or more cached representations, a
762 sender SHOULD NOT generate representation metadata other than the
763 above listed fields unless said metadata exists for the purpose of
764 guiding cache updates (e.g., Last-Modified might be useful if the
765 response does not have an ETag field).
767 Requirements on a cache that receives a 304 response are defined in
768 Section 4.2.1 of [Part6]. If the conditional request originated with
769 an outbound client, such as a user agent with its own cache sending a
770 conditional GET to a shared proxy, then the proxy SHOULD forward the
771 304 response to that client.
773 A 304 response cannot contain a message-body; it is always terminated
774 by the first empty line after the header fields.
776 4.2. 412 Precondition Failed
778 The 412 (Precondition Failed) status code indicates that one or more
779 preconditions given in the request header fields evaluated to false
780 when tested on the server. This response code allows the client to
781 place preconditions on the current resource state (its current
782 representations and metadata) and thus prevent the request method
783 from being applied if the target resource is in an unexpected state.
785 5. Evaluation and Precedence
787 For each conditional request, a server MUST evaluate the request
788 preconditions after it has successfully performed its normal request
789 checks (i.e., just before it would perform the action associated with
790 the request method). Preconditions are ignored if the server
791 determines that an error or redirect response applies before they are
792 evaluated. Otherwise, the evaluation depends on both the method
793 semantics and the choice of conditional.
795 A conditional request header field that is designed specifically for
796 cache validation, which includes If-None-Match and If-Modified-Since
797 when used in a GET or HEAD request, allows cached representations to
798 be refreshed without repeatedly transferring data already held by the
799 client. Evaluating to false is thus an indication that the client
800 can continue to use its local copy of the selected representation, as
801 indicated by the server generating a 304 (Not Modified) response that
802 includes only those header fields useful for refreshing the cached
803 representation.
805 All other conditionals are intended to signal failure when the
806 precondition evaluates to false. For example, an If-Match
807 conditional sent with a state-changing method (e.g., POST, PUT,
808 DELETE) is intended to prevent the request from taking effect on the
809 target resource if the resource state does not match the expected
810 state. In other words, evaluating the condition to false means that
811 the resource has been changed by some other client, perhaps by
812 another user attempting to edit the same resource, and thus
813 preventing the request from being applied saves the client from
814 overwriting some other client's work. This result is indicated by
815 the server generating a 412 (Precondition Failed) response.
817 The conditional request header fields defined by this specification
818 are ignored for request methods that never involve the selection or
819 modification of a selected representation (e.g., CONNECT, OPTIONS,
820 and TRACE). Other conditional request header fields, defined by
821 extensions to HTTP, might place conditions on the state of the target
822 resource in general, or on a group of resources. For instance, the
823 If header field in WebDAV can make a request conditional on various
824 aspects (such as locks) of multiple resources ([RFC4918], Section
825 10.4).
827 When more than one conditional request header field is present in a
828 request, the order in which the fields are evaluated becomes
829 important. In practice, the fields defined in this document are
830 consistently implemented in a single, logical order, due to the fact
831 that entity tags are presumed to be more accurate than date
832 validators. For example, the only reason to send both If-Modified-
833 Since and If-None-Match in the same GET request is to support
834 intermediary caches that might not have implemented If-None-Match, so
835 it makes sense to ignore the If-Modified-Since when entity tags are
836 understood and available for the selected representation.
838 The general rule of conditional precedence is that exact match
839 conditions are evaluated before cache-validating conditions and,
840 within that order, last-modified conditions are only evaluated if the
841 corresponding entity tag condition is not present (or not applicable
842 because the selected representation does not have an entity tag).
844 Specifically, the fields defined by this specification are evaluated
845 as follows:
847 1. When If-Match is present, evaluate it:
849 * if true, continue to step 3
851 * if false, respond 412 (Precondition Failed)
853 2. When If-Match is not present and If-Unmodified-Since is present,
854 evaluate it:
856 * if true, continue to step 3
858 * if false, respond 412 (Precondition Failed)
860 3. When If-None-Match is present, evaluate it:
862 * if true, continue to step 5
864 * if false for GET/HEAD, respond 304 (Not Modified)
866 * if false for other methods, respond 412 (Precondition Failed)
868 4. When the method is GET or HEAD, If-None-Match is not present, and
869 If-Modified-Since is present, evaluate it:
871 * if true, continue to step 5
873 * if false, respond 304 (Not Modified)
875 5. When the method is GET and both Range and If-Range are present,
876 evaluate If-Range:
878 * if the validator matches and the Range specification is
879 applicable to the selected representation, respond 206
880 (Partial Content) [Part5]
882 6. Otherwise,
884 * all conditions are met, so perform the requested action and
885 respond according to its success or failure.
887 Any extension to HTTP/1.1 that defines additional conditional request
888 header fields ought to define its own expectations regarding the
889 order for evaluating such fields in relation to those defined in this
890 document and other conditionals that might be found in practice.
892 6. IANA Considerations
894 6.1. Status Code Registration
896 The HTTP Status Code Registry located at
897 shall be updated
898 with the registrations below:
900 +-------+---------------------+-------------+
901 | Value | Description | Reference |
902 +-------+---------------------+-------------+
903 | 304 | Not Modified | Section 4.1 |
904 | 412 | Precondition Failed | Section 4.2 |
905 +-------+---------------------+-------------+
907 6.2. Header Field Registration
909 HTTP header fields are registered within the Message Header Field
910 Registry maintained at .
913 This document defines the following HTTP header fields, so their
914 associated registry entries shall be updated according to the
915 permanent registrations below (see [BCP90]):
917 +---------------------+----------+----------+-------------+
918 | Header Field Name | Protocol | Status | Reference |
919 +---------------------+----------+----------+-------------+
920 | ETag | http | standard | Section 2.3 |
921 | If-Match | http | standard | Section 3.1 |
922 | If-Modified-Since | http | standard | Section 3.3 |
923 | If-None-Match | http | standard | Section 3.2 |
924 | If-Unmodified-Since | http | standard | Section 3.4 |
925 | Last-Modified | http | standard | Section 2.2 |
926 +---------------------+----------+----------+-------------+
928 The change controller is: "IETF (iesg@ietf.org) - Internet
929 Engineering Task Force".
931 7. Security Considerations
933 This section is meant to inform developers, information providers,
934 and users of known security concerns specific to the HTTP/1.1
935 conditional request mechanisms. More general security considerations
936 are addressed in HTTP messaging [Part1] and semantics [Part2].
938 The validators defined by this specification are not intended to
939 ensure the validity of a representation, guard against malicious
940 changes, or detect man-in-the-middle attacks. At best, they enable
941 more efficient cache updates and optimistic concurrent writes when
942 all participants are behaving nicely. At worst, the conditions will
943 fail and the client will receive a response that is no more harmful
944 than an HTTP exchange without conditional requests.
946 An entity-tag can be abused in ways that create privacy risks. For
947 example, a site might deliberately construct a semantically invalid
948 entity-tag that is unique to the user or user agent, send it in a
949 cacheable response with a long freshness time, and then read that
950 entity-tag in later conditional requests as a means of re-identifying
951 that user or user agent. Such an identifying tag would become a
952 persistent identifier for as long as the user agent retained the
953 original cache entry. User agents that cache representations ought
954 to ensure that the cache is cleared or replaced whenever the user
955 performs privacy-maintaining actions, such as clearing stored cookies
956 or changing to a private browsing mode.
958 8. Acknowledgments
960 See Section 9 of [Part1].
962 9. References
964 9.1. Normative References
966 [Part1] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
967 Protocol (HTTP/1.1): Message Syntax and Routing",
968 draft-ietf-httpbis-p1-messaging-23 (work in progress),
969 July 2013.
971 [Part2] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
972 Protocol (HTTP/1.1): Semantics and Content",
973 draft-ietf-httpbis-p2-semantics-23 (work in progress),
974 July 2013.
976 [Part5] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed.,
977 "Hypertext Transfer Protocol (HTTP/1.1): Range Requests",
978 draft-ietf-httpbis-p5-range-23 (work in progress),
979 July 2013.
981 [Part6] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke,
982 Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching",
983 draft-ietf-httpbis-p6-cache-23 (work in progress),
984 July 2013.
986 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
987 Requirement Levels", BCP 14, RFC 2119, March 1997.
989 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
990 Specifications: ABNF", STD 68, RFC 5234, January 2008.
992 9.2. Informative References
994 [BCP90] Klyne, G., Nottingham, M., and J. Mogul, "Registration
995 Procedures for Message Header Fields", BCP 90, RFC 3864,
996 September 2004.
998 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
999 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
1000 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
1002 [RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed
1003 Authoring and Versioning (WebDAV)", RFC 4918, June 2007.
1005 Appendix A. Changes from RFC 2616
1007 The definition of validator weakness has been expanded and clarified.
1008 (Section 2.1)
1010 Weak entity-tags are now allowed in all requests except range
1011 requests (Sections 2.1 and 3.2).
1013 The ETag header field ABNF has been changed to not use quoted-string,
1014 thus avoiding escaping issues. (Section 2.3)
1016 ETag is defined to provide an entity tag for the selected
1017 representation, thereby clarifying what it applies to in various
1018 situations (such as a PUT response). (Section 2.3)
1020 The precedence for evaluation of conditional requests has been
1021 defined. (Section 5)
1023 Appendix B. Imported ABNF
1025 The following core rules are included by reference, as defined in
1026 Appendix B.1 of [RFC5234]: ALPHA (letters), CR (carriage return),
1027 CRLF (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double
1028 quote), HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed), OCTET (any
1029 8-bit sequence of data), SP (space), and VCHAR (any visible US-ASCII
1030 character).
1032 The rules below are defined in [Part1]:
1034 OWS =
1035 obs-text =
1037 The rules below are defined in other parts:
1039 HTTP-date =
1041 Appendix C. Collected ABNF
1043 In the collected ABNF below, list rules are expanded as per Section
1044 1.2 of [Part1].
1046 ETag = entity-tag
1048 HTTP-date =
1050 If-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
1051 entity-tag ] ) )
1052 If-Modified-Since = HTTP-date
1053 If-None-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
1054 entity-tag ] ) )
1055 If-Unmodified-Since = HTTP-date
1057 Last-Modified = HTTP-date
1059 OWS =
1061 entity-tag = [ weak ] opaque-tag
1062 etagc = "!" / %x23-7E ; '#'-'~'
1063 / obs-text
1065 obs-text =
1066 opaque-tag = DQUOTE *etagc DQUOTE
1068 weak = %x57.2F ; W/
1070 Appendix D. Change Log (to be removed by RFC Editor before publication)
1072 Changes up to the first Working Group Last Call draft are summarized
1073 in .
1076 D.1. Since draft-ietf-httpbis-p4-conditional-19
1078 Closed issues:
1080 o : "Need to
1081 clarify eval order/interaction of conditional headers"
1083 o : "Required
1084 headers on 304 and 206"
1086 o : "Optionality
1087 of Conditional Request Support"
1089 o : "ETags and
1090 Conditional Requests"
1092 o : "ABNF
1093 requirements for recipients"
1095 o : "Rare cases"
1097 o : "Conditional
1098 Request Security Considerations"
1100 o : "If-Modified-
1101 Since lacks definition for method != GET"
1103 o : "refactor
1104 conditional header field descriptions"
1106 D.2. Since draft-ietf-httpbis-p4-conditional-20
1108 o Conformance criteria and considerations regarding error handling
1109 are now defined in Part 1.
1111 D.3. Since draft-ietf-httpbis-p4-conditional-21
1113 Closed issues:
1115 o : "Conditional
1116 GET text"
1118 o : "Optionality
1119 of Conditional Request Support"
1121 o : "unclear prose
1122 in definition of 304"
1124 o : "ETags and
1125 Conneg"
1127 o : "Comparison
1128 function for If-Match and If-None-Match"
1130 o : "304 without
1131 validator"
1133 o : "If-Match and
1134 428"
1136 D.4. Since draft-ietf-httpbis-p4-conditional-22
1138 Closed issues:
1140 o : "explain list
1141 expansion in ABNF appendices"
1143 o : "incorrect
1144 example dates"
1146 Partly resolved issues:
1148 o : "Editorial
1149 suggestions"
1151 Index
1153 3
1154 304 Not Modified (status code) 17
1156 4
1157 412 Precondition Failed (status code) 17
1159 E
1160 ETag header field 9
1162 G
1163 Grammar
1164 entity-tag 9
1165 ETag 9
1166 etagc 9
1167 If-Match 13
1168 If-Modified-Since 15
1169 If-None-Match 14
1170 If-Unmodified-Since 16
1171 Last-Modified 7
1172 opaque-tag 9
1173 weak 9
1175 I
1176 If-Match header field 13
1177 If-Modified-Since header field 15
1178 If-None-Match header field 14
1179 If-Unmodified-Since header field 16
1181 L
1182 Last-Modified header field 7
1184 M
1185 metadata 5
1187 S
1188 selected representation 4
1190 V
1191 validator 5
1192 strong 5
1193 weak 5
1195 Authors' Addresses
1197 Roy T. Fielding (editor)
1198 Adobe Systems Incorporated
1199 345 Park Ave
1200 San Jose, CA 95110
1201 USA
1203 EMail: fielding@gbiv.com
1204 URI: http://roy.gbiv.com/
1206 Julian F. Reschke (editor)
1207 greenbytes GmbH
1208 Hafenweg 16
1209 Muenster, NW 48155
1210 Germany
1212 EMail: julian.reschke@greenbytes.de
1213 URI: http://greenbytes.de/tech/webdav/