idnits 2.17.1
draft-ietf-httpbis-p4-conditional-19.txt:
Checking boilerplate required by RFC 5378 and the IETF Trust (see
https://trustee.ietf.org/license-info):
----------------------------------------------------------------------------
No issues found here.
Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt:
----------------------------------------------------------------------------
No issues found here.
Checking nits according to https://www.ietf.org/id-info/checklist :
----------------------------------------------------------------------------
No issues found here.
Miscellaneous warnings:
----------------------------------------------------------------------------
== The copyright year in the IETF Trust and authors Copyright Line does not
match the current year
-- The document seems to contain a disclaimer for pre-RFC5378 work, 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 (March 12, 2012) is 4399 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-19
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p2-semantics-19
== Outdated reference: A later version (-20) exists of
draft-ietf-httpbis-p3-payload-19
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p5-range-19
== Outdated reference: A later version (-26) exists of
draft-ietf-httpbis-p6-cache-19
-- 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 (~~), 6 warnings (==), 3 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) Y. Lafon, Ed.
5 Intended status: Standards Track W3C
6 Expires: September 13, 2012 J. Reschke, Ed.
7 greenbytes
8 March 12, 2012
10 HTTP/1.1, part 4: Conditional Requests
11 draft-ietf-httpbis-p4-conditional-19
13 Abstract
15 The Hypertext Transfer Protocol (HTTP) is an application-level
16 protocol for distributed, collaborative, hypertext information
17 systems. HTTP has been in use by the World Wide Web global
18 information initiative since 1990. This document is Part 4 of the
19 seven-part specification that defines the protocol referred to as
20 "HTTP/1.1" and, taken together, obsoletes RFC 2616.
22 Part 4 defines request header fields for indicating conditional
23 requests and the rules for constructing responses to those requests.
25 Editorial Note (To be removed by RFC Editor)
27 Discussion of this draft should take place on the HTTPBIS working
28 group mailing list (ietf-http-wg@w3.org), which is archived at
29 .
31 The current issues list is at
32 and related
33 documents (including fancy diffs) can be found at
34 .
36 The changes in this draft are summarized in Appendix C.20.
38 Status of This Memo
40 This Internet-Draft is submitted in full conformance with the
41 provisions of BCP 78 and BCP 79.
43 Internet-Drafts are working documents of the Internet Engineering
44 Task Force (IETF). Note that other groups may also distribute
45 working documents as Internet-Drafts. The list of current Internet-
46 Drafts is at http://datatracker.ietf.org/drafts/current/.
48 Internet-Drafts are draft documents valid for a maximum of six months
49 and may be updated, replaced, or obsoleted by other documents at any
50 time. It is inappropriate to use Internet-Drafts as reference
51 material or to cite them other than as "work in progress."
53 This Internet-Draft will expire on September 13, 2012.
55 Copyright Notice
57 Copyright (c) 2012 IETF Trust and the persons identified as the
58 document authors. All rights reserved.
60 This document is subject to BCP 78 and the IETF Trust's Legal
61 Provisions Relating to IETF Documents
62 (http://trustee.ietf.org/license-info) in effect on the date of
63 publication of this document. Please review these documents
64 carefully, as they describe your rights and restrictions with respect
65 to this document. Code Components extracted from this document must
66 include Simplified BSD License text as described in Section 4.e of
67 the Trust Legal Provisions and are provided without warranty as
68 described in the Simplified BSD License.
70 This document may contain material from IETF Documents or IETF
71 Contributions published or made publicly available before November
72 10, 2008. The person(s) controlling the copyright in some of this
73 material may not have granted the IETF Trust the right to allow
74 modifications of such material outside the IETF Standards Process.
75 Without obtaining an adequate license from the person(s) controlling
76 the copyright in such materials, this document may not be modified
77 outside the IETF Standards Process, and derivative works of it may
78 not be created outside the IETF Standards Process, except to format
79 it for publication as an RFC or to translate it into languages other
80 than English.
82 Table of Contents
84 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4
85 1.1. Conformance and Error Handling . . . . . . . . . . . . . . 4
86 1.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 5
87 2. Validators . . . . . . . . . . . . . . . . . . . . . . . . . . 5
88 2.1. Weak versus Strong . . . . . . . . . . . . . . . . . . . . 5
89 2.2. Last-Modified . . . . . . . . . . . . . . . . . . . . . . 7
90 2.2.1. Generation . . . . . . . . . . . . . . . . . . . . . . 7
91 2.2.2. Comparison . . . . . . . . . . . . . . . . . . . . . . 8
92 2.3. ETag . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
93 2.3.1. Generation . . . . . . . . . . . . . . . . . . . . . . 10
94 2.3.2. Comparison . . . . . . . . . . . . . . . . . . . . . . 11
95 2.3.3. Example: Entity-tags varying on Content-Negotiated
96 Resources . . . . . . . . . . . . . . . . . . . . . . 11
98 2.4. Rules for When to Use Entity-tags and Last-Modified
99 Dates . . . . . . . . . . . . . . . . . . . . . . . . . . 12
100 3. Precondition Header Fields . . . . . . . . . . . . . . . . . . 14
101 3.1. If-Match . . . . . . . . . . . . . . . . . . . . . . . . . 14
102 3.2. If-None-Match . . . . . . . . . . . . . . . . . . . . . . 15
103 3.3. If-Modified-Since . . . . . . . . . . . . . . . . . . . . 16
104 3.4. If-Unmodified-Since . . . . . . . . . . . . . . . . . . . 17
105 3.5. If-Range . . . . . . . . . . . . . . . . . . . . . . . . . 18
106 4. Status Code Definitions . . . . . . . . . . . . . . . . . . . 18
107 4.1. 304 Not Modified . . . . . . . . . . . . . . . . . . . . . 18
108 4.2. 412 Precondition Failed . . . . . . . . . . . . . . . . . 19
109 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 19
110 5.1. Status Code Registration . . . . . . . . . . . . . . . . . 19
111 5.2. Header Field Registration . . . . . . . . . . . . . . . . 19
112 6. Security Considerations . . . . . . . . . . . . . . . . . . . 20
113 7. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 20
114 8. References . . . . . . . . . . . . . . . . . . . . . . . . . . 20
115 8.1. Normative References . . . . . . . . . . . . . . . . . . . 20
116 8.2. Informative References . . . . . . . . . . . . . . . . . . 21
117 Appendix A. Changes from RFC 2616 . . . . . . . . . . . . . . . . 21
118 Appendix B. Collected ABNF . . . . . . . . . . . . . . . . . . . 22
119 Appendix C. Change Log (to be removed by RFC Editor before
120 publication) . . . . . . . . . . . . . . . . . . . . 22
121 C.1. Since RFC 2616 . . . . . . . . . . . . . . . . . . . . . . 22
122 C.2. Since draft-ietf-httpbis-p4-conditional-00 . . . . . . . . 22
123 C.3. Since draft-ietf-httpbis-p4-conditional-01 . . . . . . . . 23
124 C.4. Since draft-ietf-httpbis-p4-conditional-02 . . . . . . . . 23
125 C.5. Since draft-ietf-httpbis-p4-conditional-03 . . . . . . . . 23
126 C.6. Since draft-ietf-httpbis-p4-conditional-04 . . . . . . . . 23
127 C.7. Since draft-ietf-httpbis-p4-conditional-05 . . . . . . . . 24
128 C.8. Since draft-ietf-httpbis-p4-conditional-06 . . . . . . . . 24
129 C.9. Since draft-ietf-httpbis-p4-conditional-07 . . . . . . . . 24
130 C.10. Since draft-ietf-httpbis-p4-conditional-08 . . . . . . . . 24
131 C.11. Since draft-ietf-httpbis-p4-conditional-09 . . . . . . . . 24
132 C.12. Since draft-ietf-httpbis-p4-conditional-10 . . . . . . . . 24
133 C.13. Since draft-ietf-httpbis-p4-conditional-11 . . . . . . . . 25
134 C.14. Since draft-ietf-httpbis-p4-conditional-12 . . . . . . . . 25
135 C.15. Since draft-ietf-httpbis-p4-conditional-13 . . . . . . . . 25
136 C.16. Since draft-ietf-httpbis-p4-conditional-14 . . . . . . . . 25
137 C.17. Since draft-ietf-httpbis-p4-conditional-15 . . . . . . . . 25
138 C.18. Since draft-ietf-httpbis-p4-conditional-16 . . . . . . . . 25
139 C.19. Since draft-ietf-httpbis-p4-conditional-17 . . . . . . . . 26
140 C.20. Since draft-ietf-httpbis-p4-conditional-18 . . . . . . . . 26
141 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
143 1. Introduction
145 This document defines the HTTP/1.1 conditional request mechanisms,
146 including both metadata for indicating/observing changes in resource
147 representations and request header fields that specify preconditions
148 on that metadata be checked before performing the request method.
149 Conditional GET requests are the most efficient mechanism for HTTP
150 cache updates [Part6]. Conditionals can also be applied to state-
151 changing methods, such as PUT and DELETE, to prevent the "lost
152 update" problem: one client accidentally overwriting the work of
153 another client that has been acting in parallel.
155 Conditional request preconditions are based on the state of the
156 target resource as a whole (its current value set) or the state as
157 observed in a previously obtained representation (one value in that
158 set). A resource might have multiple current representations, each
159 with its own observable state. The conditional request mechanisms
160 assume that the mapping of requests to corresponding representations
161 will be consistent over time if the server intends to take advantage
162 of conditionals. Regardless, if the mapping is inconsistent and the
163 server is unable to select the appropriate representation, then no
164 harm will result when the precondition evaluates to false.
166 We use the term "selected representation" to refer to the current
167 representation of the target resource that would have been selected
168 in a successful response if the same request had used the method GET
169 and had excluded all of the conditional request header fields. The
170 conditional request preconditions are evaluated by comparing the
171 values provided in the request header fields to the current metadata
172 for the selected representation.
174 1.1. Conformance and Error Handling
176 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
177 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
178 document are to be interpreted as described in [RFC2119].
180 This document defines conformance criteria for several roles in HTTP
181 communication, including Senders, Recipients, Clients, Servers, User-
182 Agents, Origin Servers, Intermediaries, Proxies and Gateways. See
183 Section 2 of [Part1] for definitions of these terms.
185 An implementation is considered conformant if it complies with all of
186 the requirements associated with its role(s). Note that SHOULD-level
187 requirements are relevant here, unless one of the documented
188 exceptions is applicable.
190 This document also uses ABNF to define valid protocol elements
191 (Section 1.2). In addition to the prose requirements placed upon
192 them, Senders MUST NOT generate protocol elements that are invalid.
194 Unless noted otherwise, Recipients MAY take steps to recover a usable
195 protocol element from an invalid construct. However, HTTP does not
196 define specific error handling mechanisms, except in cases where it
197 has direct impact on security. This is because different uses of the
198 protocol require different error handling strategies; for example, a
199 Web browser may wish to transparently recover from a response where
200 the Location header field doesn't parse according to the ABNF,
201 whereby in a systems control protocol using HTTP, this type of error
202 recovery could lead to dangerous consequences.
204 1.2. Syntax Notation
206 This specification uses the Augmented Backus-Naur Form (ABNF)
207 notation of [RFC5234] with the list rule extension defined in Section
208 1.2 of [Part1]. Appendix B shows the collected ABNF with the list
209 rule expanded.
211 The following core rules are included by reference, as defined in
212 [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF
213 (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote),
214 HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed), OCTET (any 8-bit
215 sequence of data), SP (space), and VCHAR (any visible US-ASCII
216 character).
218 The ABNF rules below are defined in [Part1] and [Part2]:
220 OWS =
221 obs-text =
222 HTTP-date =
224 2. Validators
226 This specification defines two forms of metadata that are commonly
227 used to observe resource state and test for preconditions:
228 modification dates and opaque entity tags. Additional metadata that
229 reflects resource state has been defined by various extensions of
230 HTTP, such as WebDAV [RFC4918], that are beyond the scope of this
231 specification. A resource metadata value is referred to as a
232 "validator" when it is used within a precondition.
234 2.1. Weak versus Strong
236 Validators come in two flavors: strong or weak. Weak validators are
237 easy to generate but are far less useful for comparisons. Strong
238 validators are ideal for comparisons but can be very difficult (and
239 occasionally impossible) to generate efficiently. Rather than impose
240 that all forms of resource adhere to the same strength of validator,
241 HTTP exposes the type of validator in use and imposes restrictions on
242 when weak validators can be used as preconditions.
244 A "strong validator" is a representation metadata value that MUST be
245 changed to a new, previously unused or guaranteed unique, value
246 whenever a change occurs to the representation data such that a
247 change would be observable in the payload body of a 200 response to
248 GET. A strong validator MAY be changed for other reasons, such as
249 when a semantically significant part of the representation metadata
250 is changed (e.g., Content-Type), but it is in the best interests of
251 the origin server to only change the value when it is necessary to
252 invalidate the stored responses held by remote caches and authoring
253 tools. A strong validator MUST be unique across all representations
254 of a given resource, such that no two representations of that
255 resource share the same validator unless their payload body would be
256 identical.
258 Cache entries might persist for arbitrarily long periods, regardless
259 of expiration times. Thus, a cache might attempt to validate an
260 entry using a validator that it obtained in the distant past. A
261 strong validator MUST be unique across all versions of all
262 representations associated with a particular resource over time.
263 However, there is no implication of uniqueness across representations
264 of different resources (i.e., the same strong validator might be in
265 use for representations of multiple resources at the same time and
266 does not imply that those representations are equivalent).
268 There are a variety of strong validators used in practice. The best
269 are based on strict revision control, wherein each change to a
270 representation always results in a unique node name and revision
271 identifier being assigned before the representation is made
272 accessible to GET. A cryptographic hash function applied to the
273 representation data is also sufficient if the data is available prior
274 to the response header fields being sent and the digest does not need
275 to be recalculated every time a validation request is received.
276 However, if a resource has distinct representations that differ only
277 in their metadata, such as might occur with content negotiation over
278 media types that happen to share the same data format, then a server
279 SHOULD incorporate additional information in the validator to
280 distinguish those representations and avoid confusing cache behavior.
282 In contrast, a "weak validator" is a representation metadata value
283 that might not be changed for every change to the representation
284 data. This weakness might be due to limitations in how the value is
285 calculated, such as clock resolution or an inability to ensure
286 uniqueness for all possible representations of the resource, or due
287 to a desire by the resource owner to group representations by some
288 self-determined set of equivalency rather than unique sequences of
289 data. A weak entity-tag SHOULD change whenever the origin server
290 considers prior representations to be unacceptable as a substitute
291 for the current representation. In other words, a weak entity-tag
292 SHOULD change whenever the origin server wants caches to invalidate
293 old responses.
295 For example, the representation of a weather report that changes in
296 content every second, based on dynamic measurements, might be grouped
297 into sets of equivalent representations (from the origin server's
298 perspective) with the same weak validator in order to allow cached
299 representations to be valid for a reasonable period of time (perhaps
300 adjusted dynamically based on server load or weather quality).
301 Likewise, a representation's modification time, if defined with only
302 one-second resolution, might be a weak validator if it is possible
303 for the representation to be modified twice during a single second
304 and retrieved between those modifications.
306 A "use" of a validator occurs when either a client generates a
307 request and includes the validator in a precondition or when a server
308 compares two validators. Weak validators are only usable in contexts
309 that do not depend on exact equality of a representation's payload
310 body. Strong validators are usable and preferred for all conditional
311 requests, including cache validation, partial content ranges, and
312 "lost update" avoidance.
314 2.2. Last-Modified
316 The "Last-Modified" header field indicates the date and time at which
317 the origin server believes the selected representation was last
318 modified.
320 Last-Modified = HTTP-date
322 An example of its use is
324 Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
326 2.2.1. Generation
328 Origin servers SHOULD send Last-Modified for any selected
329 representation for which a last modification date can be reasonably
330 and consistently determined, since its use in conditional requests
331 and evaluating cache freshness ([Part6]) results in a substantial
332 reduction of HTTP traffic on the Internet and can be a significant
333 factor in improving service scalability and reliability.
335 A representation is typically the sum of many parts behind the
336 resource interface. The last-modified time would usually be the most
337 recent time that any of those parts were changed. How that value is
338 determined for any given resource is an implementation detail beyond
339 the scope of this specification. What matters to HTTP is how
340 recipients of the Last-Modified header field can use its value to
341 make conditional requests and test the validity of locally cached
342 responses.
344 An origin server SHOULD obtain the Last-Modified value of the
345 representation as close as possible to the time that it generates the
346 Date field-value for its response. This allows a recipient to make
347 an accurate assessment of the representation's modification time,
348 especially if the representation changes near the time that the
349 response is generated.
351 An origin server with a clock MUST NOT send a Last-Modified date that
352 is later than the server's time of message origination (Date). If
353 the last modification time is derived from implementation-specific
354 metadata that evaluates to some time in the future, according to the
355 origin server's clock, then the origin server MUST replace that value
356 with the message origination date. This prevents a future
357 modification date from having an adverse impact on cache validation.
359 An origin server without a clock MUST NOT assign Last-Modified values
360 to a response unless these values were associated with the resource
361 by some other system or user with a reliable clock.
363 2.2.2. Comparison
365 A Last-Modified time, when used as a validator in a request, is
366 implicitly weak unless it is possible to deduce that it is strong,
367 using the following rules:
369 o The validator is being compared by an origin server to the actual
370 current validator for the representation and,
372 o That origin server reliably knows that the associated
373 representation did not change twice during the second covered by
374 the presented validator.
376 or
378 o The validator is about to be used by a client in an If-Modified-
379 Since, If-Unmodified-Since header field, because the client has a
380 cache entry, or If-Range for the associated representation, and
382 o That cache entry includes a Date value, which gives the time when
383 the origin server sent the original response, and
385 o The presented Last-Modified time is at least 60 seconds before the
386 Date value.
388 or
390 o The validator is being compared by an intermediate cache to the
391 validator stored in its cache entry for the representation, and
393 o That cache entry includes a Date value, which gives the time when
394 the origin server sent the original response, and
396 o The presented Last-Modified time is at least 60 seconds before the
397 Date value.
399 This method relies on the fact that if two different responses were
400 sent by the origin server during the same second, but both had the
401 same Last-Modified time, then at least one of those responses would
402 have a Date value equal to its Last-Modified time. The arbitrary 60-
403 second limit guards against the possibility that the Date and Last-
404 Modified values are generated from different clocks, or at somewhat
405 different times during the preparation of the response. An
406 implementation MAY use a value larger than 60 seconds, if it is
407 believed that 60 seconds is too short.
409 2.3. ETag
411 The ETag header field provides the current entity-tag for the
412 selected representation. An entity-tag is an opaque validator for
413 differentiating between multiple representations of the same
414 resource, regardless of whether those multiple representations are
415 due to resource state changes over time, content negotiation
416 resulting in multiple representations being valid at the same time,
417 or both. An entity-tag consists of an opaque quoted string, possibly
418 prefixed by a weakness indicator.
420 ETag = entity-tag
422 entity-tag = [ weak ] opaque-tag
423 weak = %x57.2F ; "W/", case-sensitive
424 opaque-tag = DQUOTE *etagc DQUOTE
425 etagc = %x21 / %x23-7E / obs-text
426 ; VCHAR except double quotes, plus obs-text
428 Note: Previously, opaque-tag was defined to be a quoted-string
429 ([RFC2616], Section 3.11), thus some recipients might perform
430 backslash unescaping. Servers therefore ought to avoid backslash
431 characters in entity tags.
433 An entity-tag can be more reliable for validation than a modification
434 date in situations where it is inconvenient to store modification
435 dates, where the one-second resolution of HTTP date values is not
436 sufficient, or where modification dates are not consistently
437 maintained.
439 Examples:
441 ETag: "xyzzy"
442 ETag: W/"xyzzy"
443 ETag: ""
445 An entity-tag can be either a weak or strong validator, with strong
446 being the default. If an origin server provides an entity-tag for a
447 representation and the generation of that entity-tag does not satisfy
448 the requirements for a strong validator (Section 2.1), then that
449 entity-tag MUST be marked as weak by prefixing its opaque value with
450 "W/" (case-sensitive).
452 2.3.1. Generation
454 The principle behind entity-tags is that only the service author
455 knows the implementation of a resource well enough to select the most
456 accurate and efficient validation mechanism for that resource, and
457 that any such mechanism can be mapped to a simple sequence of octets
458 for easy comparison. Since the value is opaque, there is no need for
459 the client to be aware of how each entity-tag is constructed.
461 For example, a resource that has implementation-specific versioning
462 applied to all changes might use an internal revision number, perhaps
463 combined with a variance identifier for content negotiation, to
464 accurately differentiate between representations. Other
465 implementations might use a stored hash of representation content, a
466 combination of various filesystem attributes, or a modification
467 timestamp that has sub-second resolution.
469 Origin servers SHOULD send ETag for any selected representation for
470 which detection of changes can be reasonably and consistently
471 determined, since the entity-tag's use in conditional requests and
472 evaluating cache freshness ([Part6]) can result in a substantial
473 reduction of HTTP network traffic and can be a significant factor in
474 improving service scalability and reliability.
476 2.3.2. Comparison
478 There are two entity-tag comparison functions, depending on whether
479 the comparison context allows the use of weak validators or not:
481 o The strong comparison function: in order to be considered equal,
482 both opaque-tags MUST be identical character-by-character, and
483 both MUST NOT be weak.
485 o The weak comparison function: in order to be considered equal,
486 both opaque-tags MUST be identical character-by-character, but
487 either or both of them MAY be tagged as "weak" without affecting
488 the result.
490 The example below shows the results for a set of entity-tag pairs,
491 and both the weak and strong comparison function results:
493 +--------+--------+-------------------+-----------------+
494 | ETag 1 | ETag 2 | Strong Comparison | Weak Comparison |
495 +--------+--------+-------------------+-----------------+
496 | W/"1" | W/"1" | no match | match |
497 | W/"1" | W/"2" | no match | no match |
498 | W/"1" | "1" | no match | match |
499 | "1" | "1" | match | match |
500 +--------+--------+-------------------+-----------------+
502 2.3.3. Example: Entity-tags varying on Content-Negotiated Resources
504 Consider a resource that is subject to content negotiation (Section 5
505 of [Part3]), and where the representations returned upon a GET
506 request vary based on the Accept-Encoding request header field
507 (Section 6.3 of [Part3]):
509 >> Request:
511 GET /index HTTP/1.1
512 Host: www.example.com
513 Accept-Encoding: gzip
515 In this case, the response might or might not use the gzip content
516 coding. If it does not, the response might look like:
518 >> Response:
520 HTTP/1.1 200 OK
521 Date: Thu, 26 Mar 2010 00:05:00 GMT
522 ETag: "123-a"
523 Content-Length: 70
524 Vary: Accept-Encoding
525 Content-Type: text/plain
527 Hello World!
528 Hello World!
529 Hello World!
530 Hello World!
531 Hello World!
533 An alternative representation that does use gzip content coding would
534 be:
536 >> Response:
538 HTTP/1.1 200 OK
539 Date: Thu, 26 Mar 2010 00:05:00 GMT
540 ETag: "123-b"
541 Content-Length: 43
542 Vary: Accept-Encoding
543 Content-Type: text/plain
544 Content-Encoding: gzip
546 ...binary data...
548 Note: Content codings are a property of the representation, so
549 therefore an entity-tag of an encoded representation must be
550 distinct from an unencoded representation to prevent conflicts
551 during cache updates and range requests. In contrast, transfer
552 codings (Section 4 of [Part1]) apply only during message transfer
553 and do not require distinct entity-tags.
555 2.4. Rules for When to Use Entity-tags and Last-Modified Dates
557 We adopt a set of rules and recommendations for origin servers,
558 clients, and caches regarding when various validator types ought to
559 be used, and for what purposes.
561 HTTP/1.1 origin servers:
563 o SHOULD send an entity-tag validator unless it is not feasible to
564 generate one.
566 o MAY send a weak entity-tag instead of a strong entity-tag, if
567 performance considerations support the use of weak entity-tags, or
568 if it is unfeasible to send a strong entity-tag.
570 o SHOULD send a Last-Modified value if it is feasible to send one.
572 In other words, the preferred behavior for an HTTP/1.1 origin server
573 is to send both a strong entity-tag and a Last-Modified value.
575 HTTP/1.1 clients:
577 o MUST use that entity-tag in any cache-conditional request (using
578 If-Match or If-None-Match) if an entity-tag has been provided by
579 the origin server.
581 o SHOULD use the Last-Modified value in non-subrange cache-
582 conditional requests (using If-Modified-Since) if only a Last-
583 Modified value has been provided by the origin server.
585 o MAY use the Last-Modified value in subrange cache-conditional
586 requests (using If-Unmodified-Since) if only a Last-Modified value
587 has been provided by an HTTP/1.0 origin server. The user agent
588 SHOULD provide a way to disable this, in case of difficulty.
590 o SHOULD use both validators in cache-conditional requests if both
591 an entity-tag and a Last-Modified value have been provided by the
592 origin server. This allows both HTTP/1.0 and HTTP/1.1 caches to
593 respond appropriately.
595 An HTTP/1.1 origin server, upon receiving a conditional request that
596 includes both a Last-Modified date (e.g., in an If-Modified-Since or
597 If-Unmodified-Since header field) and one or more entity-tags (e.g.,
598 in an If-Match, If-None-Match, or If-Range header field) as cache
599 validators, MUST NOT return a response status code of 304 (Not
600 Modified) unless doing so is consistent with all of the conditional
601 header fields in the request.
603 An HTTP/1.1 caching proxy, upon receiving a conditional request that
604 includes both a Last-Modified date and one or more entity-tags as
605 cache validators, MUST NOT return a locally cached response to the
606 client unless that cached response is consistent with all of the
607 conditional header fields in the request.
609 Note: The general principle behind these rules is that HTTP/1.1
610 servers and clients ought to transmit as much non-redundant
611 information as is available in their responses and requests.
612 HTTP/1.1 systems receiving this information will make the most
613 conservative assumptions about the validators they receive.
615 HTTP/1.0 clients and caches might ignore entity-tags. Generally,
616 last-modified values received or used by these systems will
617 support transparent and efficient caching, and so HTTP/1.1 origin
618 servers should provide Last-Modified values. In those rare cases
619 where the use of a Last-Modified value as a validator by an
620 HTTP/1.0 system could result in a serious problem, then HTTP/1.1
621 origin servers should not provide one.
623 3. Precondition Header Fields
625 This section defines the syntax and semantics of HTTP/1.1 header
626 fields for applying preconditions on requests.
628 3.1. If-Match
630 The "If-Match" header field MAY be used to make a request method
631 conditional on the current existence or value of an entity-tag for
632 one or more representations of the target resource. If-Match is
633 generally useful for resource update requests, such as PUT requests,
634 as a means for protecting against accidental overwrites when multiple
635 clients are acting in parallel on the same resource (i.e., the "lost
636 update" problem). An If-Match field-value of "*" places the
637 precondition on the existence of any current representation for the
638 target resource.
640 If-Match = "*" / 1#entity-tag
642 If any of the entity-tags listed in the If-Match field value match
643 (as per Section 2.3.2) the entity-tag of the selected representation
644 for the target resource, or if "*" is given and any current
645 representation exists for the target resource, then the server MAY
646 perform the request method as if the If-Match header field was not
647 present.
649 If none of the entity-tags match, or if "*" is given and no current
650 representation exists, the server MUST NOT perform the requested
651 method. Instead, the server MUST respond with the 412 (Precondition
652 Failed) status code.
654 If the request would, without the If-Match header field, result in
655 anything other than a 2xx or 412 status code, then the If-Match
656 header field MUST be ignored.
658 Examples:
660 If-Match: "xyzzy"
661 If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
662 If-Match: *
664 The result of a request having both an If-Match header field and
665 either an If-None-Match or an If-Modified-Since header field is
666 undefined by this specification.
668 3.2. If-None-Match
670 The "If-None-Match" header field MAY be used to make a request method
671 conditional on not matching any of the current entity-tag values for
672 representations of the target resource. If-None-Match is primarily
673 used in conditional GET requests to enable efficient updates of
674 cached information with a minimum amount of transaction overhead. A
675 client that has one or more representations previously obtained from
676 the target resource can send If-None-Match with a list of the
677 associated entity-tags in the hope of receiving a 304 response if at
678 least one of those representations matches the selected
679 representation.
681 If-None-Match MAY also be used with a value of "*" to prevent an
682 unsafe request method (e.g., PUT) from inadvertently modifying an
683 existing representation of the target resource when the client
684 believes that the resource does not have a current representation.
685 This is a variation on the "lost update" problem that might arise if
686 more than one client attempts to create an initial representation for
687 the target resource.
689 If-None-Match = "*" / 1#entity-tag
691 If any of the entity-tags listed in the If-None-Match field-value
692 match (as per Section 2.3.2) the entity-tag of the selected
693 representation, or if "*" is given and any current representation
694 exists for that resource, then the server MUST NOT perform the
695 requested method. Instead, if the request method was GET or HEAD,
696 the server SHOULD respond with a 304 (Not Modified) status code,
697 including the cache-related header fields (particularly ETag) of the
698 selected representation that has a matching entity-tag. For all
699 other request methods, the server MUST respond with a 412
700 (Precondition Failed) status code.
702 If none of the entity-tags match, then the server MAY perform the
703 requested method as if the If-None-Match header field did not exist,
704 but MUST also ignore any If-Modified-Since header field(s) in the
705 request. That is, if no entity-tags match, then the server MUST NOT
706 return a 304 (Not Modified) response.
708 If the request would, without the If-None-Match header field, result
709 in anything other than a 2xx or 304 status code, then the If-None-
710 Match header field MUST be ignored. (See Section 2.4 for a
711 discussion of server behavior when both If-Modified-Since and If-
712 None-Match appear in the same request.)
714 Examples:
716 If-None-Match: "xyzzy"
717 If-None-Match: W/"xyzzy"
718 If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
719 If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"
720 If-None-Match: *
722 The result of a request having both an If-None-Match header field and
723 either an If-Match or an If-Unmodified-Since header field is
724 undefined by this specification.
726 3.3. If-Modified-Since
728 The "If-Modified-Since" header field MAY be used to make a request
729 method conditional by modification date: if the selected
730 representation has not been modified since the time specified in this
731 field, then do not perform the request method; instead, respond as
732 detailed below.
734 If-Modified-Since = HTTP-date
736 An example of the field is:
738 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
740 A GET method with an If-Modified-Since header field and no Range
741 header field requests that the selected representation be transferred
742 only if it has been modified since the date given by the If-Modified-
743 Since header field. The algorithm for determining this includes the
744 following cases:
746 1. If the request would normally result in anything other than a 200
747 (OK) status code, or if the passed If-Modified-Since date is
748 invalid, the response is exactly the same as for a normal GET. A
749 date which is later than the server's current time is invalid.
751 2. If the selected representation has been modified since the If-
752 Modified-Since date, the response is exactly the same as for a
753 normal GET.
755 3. If the selected representation has not been modified since a
756 valid If-Modified-Since date, the server SHOULD return a 304 (Not
757 Modified) response.
759 The purpose of this feature is to allow efficient updates of cached
760 information with a minimum amount of transaction overhead.
762 Note: The Range header field modifies the meaning of If-Modified-
763 Since; see Section 5.4 of [Part5] for full details.
765 Note: If-Modified-Since times are interpreted by the server, whose
766 clock might not be synchronized with the client.
768 Note: When handling an If-Modified-Since header field, some
769 servers will use an exact date comparison function, rather than a
770 less-than function, for deciding whether to send a 304 (Not
771 Modified) response. To get best results when sending an If-
772 Modified-Since header field for cache validation, clients are
773 advised to use the exact date string received in a previous Last-
774 Modified header field whenever possible.
776 Note: If a client uses an arbitrary date in the If-Modified-Since
777 header field instead of a date taken from the Last-Modified header
778 field for the same request, the client needs to be aware that this
779 date is interpreted in the server's understanding of time.
780 Unsynchronized clocks and rounding problems, due to the different
781 encodings of time between the client and server, are concerns.
782 This includes the possibility of race conditions if the document
783 has changed between the time it was first requested and the If-
784 Modified-Since date of a subsequent request, and the possibility
785 of clock-skew-related problems if the If-Modified-Since date is
786 derived from the client's clock without correction to the server's
787 clock. Corrections for different time bases between client and
788 server are at best approximate due to network latency.
790 The result of a request having both an If-Modified-Since header field
791 and either an If-Match or an If-Unmodified-Since header field is
792 undefined by this specification.
794 3.4. If-Unmodified-Since
796 The "If-Unmodified-Since" header field MAY be used to make a request
797 method conditional by modification date: if the selected
798 representation has been modified since the time specified in this
799 field, then the server MUST NOT perform the requested operation and
800 MUST instead respond with the 412 (Precondition Failed) status code.
801 If the selected representation has not been modified since the time
802 specified in this field, the server SHOULD perform the request method
803 as if the If-Unmodified-Since header field were not present.
805 If-Unmodified-Since = HTTP-date
807 An example of the field is:
809 If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
811 If the request normally (i.e., without the If-Unmodified-Since header
812 field) would result in anything other than a 2xx or 412 status code,
813 the If-Unmodified-Since header field SHOULD be ignored.
815 If the specified date is invalid, the header field MUST be ignored.
817 The result of a request having both an If-Unmodified-Since header
818 field and either an If-None-Match or an If-Modified-Since header
819 field is undefined by this specification.
821 3.5. If-Range
823 The If-Range header field provides a special conditional request
824 mechanism that is similar to If-Match and If-Unmodified-Since but
825 specific to HTTP range requests. If-Range is defined in Section 5.3
826 of [Part5].
828 4. Status Code Definitions
830 4.1. 304 Not Modified
832 The 304 status code indicates that a conditional GET request has been
833 received and would have resulted in a 200 (OK) response if it were
834 not for the fact that the condition has evaluated to false. In other
835 words, there is no need for the server to transfer a representation
836 of the target resource because the client's request indicates that it
837 already has a valid representation, as indicated by the 304 response
838 header fields, and is therefore redirecting the client to make use of
839 that stored representation as if it were the payload of a 200
840 response. The 304 response MUST NOT contain a message-body, and thus
841 is always terminated by the first empty line after the header fields.
843 A 304 response MUST include a Date header field (Section 10.2 of
844 [Part2]) unless the origin server does not have a clock that can
845 provide a reasonable approximation of the current time. If a 200
846 response to the same request would have included any of the header
847 fields Cache-Control, Content-Location, ETag, Expires, or Vary, then
848 those same header fields MUST be sent in a 304 response.
850 Since the goal of a 304 response is to minimize information transfer
851 when the recipient already has one or more cached representations,
852 the response SHOULD NOT include representation metadata other than
853 the above listed fields unless said metadata exists for the purpose
854 of guiding cache updates (e.g., future HTTP extensions).
856 If the recipient of a 304 response does not have a cached
857 representation corresponding to the entity-tag indicated by the 304
858 response, then the recipient MUST NOT use the 304 to update its own
859 cache. If this conditional request originated with an outbound
860 client, such as a user agent with its own cache sending a conditional
861 GET to a shared proxy, then the 304 response MAY be forwarded to the
862 outbound client. Otherwise, the recipient MUST disregard the 304
863 response and repeat the request without any preconditions.
865 If a cache uses a received 304 response to update a cache entry, the
866 cache MUST update the entry to reflect any new field values given in
867 the response.
869 4.2. 412 Precondition Failed
871 The 412 status code indicates that one or more preconditions given in
872 the request header fields evaluated to false when tested on the
873 server. This response code allows the client to place preconditions
874 on the current resource state (its current representations and
875 metadata) and thus prevent the request method from being applied if
876 the target resource is in an unexpected state.
878 5. IANA Considerations
880 5.1. Status Code Registration
882 The HTTP Status Code Registry located at
883 shall be updated
884 with the registrations below:
886 +-------+---------------------+-------------+
887 | Value | Description | Reference |
888 +-------+---------------------+-------------+
889 | 304 | Not Modified | Section 4.1 |
890 | 412 | Precondition Failed | Section 4.2 |
891 +-------+---------------------+-------------+
893 5.2. Header Field Registration
895 The Message Header Field Registry located at shall be
897 updated with the permanent registrations below (see [RFC3864]):
899 +---------------------+----------+----------+-------------+
900 | Header Field Name | Protocol | Status | Reference |
901 +---------------------+----------+----------+-------------+
902 | ETag | http | standard | Section 2.3 |
903 | If-Match | http | standard | Section 3.1 |
904 | If-Modified-Since | http | standard | Section 3.3 |
905 | If-None-Match | http | standard | Section 3.2 |
906 | If-Unmodified-Since | http | standard | Section 3.4 |
907 | Last-Modified | http | standard | Section 2.2 |
908 +---------------------+----------+----------+-------------+
910 The change controller is: "IETF (iesg@ietf.org) - Internet
911 Engineering Task Force".
913 6. Security Considerations
915 No additional security considerations have been identified beyond
916 those applicable to HTTP in general [Part1].
918 7. Acknowledgments
920 See Section 9 of [Part1].
922 8. References
924 8.1. Normative References
926 [Part1] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed.,
927 "HTTP/1.1, part 1: URIs, Connections, and Message
928 Parsing", draft-ietf-httpbis-p1-messaging-19 (work in
929 progress), March 2012.
931 [Part2] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed.,
932 "HTTP/1.1, part 2: Message Semantics",
933 draft-ietf-httpbis-p2-semantics-19 (work in progress),
934 March 2012.
936 [Part3] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed.,
937 "HTTP/1.1, part 3: Message Payload and Content
938 Negotiation", draft-ietf-httpbis-p3-payload-19 (work in
939 progress), March 2012.
941 [Part5] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed.,
942 "HTTP/1.1, part 5: Range Requests and Partial Responses",
943 draft-ietf-httpbis-p5-range-19 (work in progress),
944 March 2012.
946 [Part6] Fielding, R., Ed., Lafon, Y., Ed., Nottingham, M., Ed.,
947 and J. Reschke, Ed., "HTTP/1.1, part 6: Caching",
948 draft-ietf-httpbis-p6-cache-19 (work in progress),
949 March 2012.
951 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
952 Requirement Levels", BCP 14, RFC 2119, March 1997.
954 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
955 Specifications: ABNF", STD 68, RFC 5234, January 2008.
957 8.2. Informative References
959 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
960 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
961 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
963 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration
964 Procedures for Message Header Fields", BCP 90, RFC 3864,
965 September 2004.
967 [RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed
968 Authoring and Versioning (WebDAV)", RFC 4918, June 2007.
970 Appendix A. Changes from RFC 2616
972 Allow weak entity-tags in all requests except range requests
973 (Sections 2.1 and 3.2).
975 Change ETag header field ABNF not to use quoted-string, thus avoiding
976 escaping issues. (Section 2.3)
978 Change ABNF productions for header fields to only define the field
979 value. (Section 3)
981 Appendix B. Collected ABNF
983 ETag = entity-tag
985 HTTP-date =
987 If-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
988 entity-tag ] ) )
989 If-Modified-Since = HTTP-date
990 If-None-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
991 entity-tag ] ) )
992 If-Unmodified-Since = HTTP-date
994 Last-Modified = HTTP-date
996 OWS =
998 entity-tag = [ weak ] opaque-tag
999 etagc = "!" / %x23-7E ; '#'-'~'
1000 / obs-text
1002 obs-text =
1003 opaque-tag = DQUOTE *etagc DQUOTE
1005 weak = %x57.2F ; W/
1007 ABNF diagnostics:
1009 ; ETag defined but not used
1010 ; If-Match defined but not used
1011 ; If-Modified-Since defined but not used
1012 ; If-None-Match defined but not used
1013 ; If-Unmodified-Since defined but not used
1014 ; Last-Modified defined but not used
1016 Appendix C. Change Log (to be removed by RFC Editor before publication)
1018 C.1. Since RFC 2616
1020 Extracted relevant partitions from [RFC2616].
1022 C.2. Since draft-ietf-httpbis-p4-conditional-00
1024 Closed issues:
1026 o : "Normative and
1027 Informative references"
1029 Other changes:
1031 o Move definitions of 304 and 412 condition codes from Part2.
1033 C.3. Since draft-ietf-httpbis-p4-conditional-01
1035 Ongoing work on ABNF conversion
1036 ():
1038 o Add explicit references to BNF syntax and rules imported from
1039 other parts of the specification.
1041 C.4. Since draft-ietf-httpbis-p4-conditional-02
1043 Closed issues:
1045 o : "Weak ETags on
1046 non-GET requests"
1048 Ongoing work on IANA Message Header Field Registration
1049 ():
1051 o Reference RFC 3984, and update header field registrations for
1052 header fields defined in this document.
1054 C.5. Since draft-ietf-httpbis-p4-conditional-03
1056 Closed issues:
1058 o : "Examples for
1059 ETag matching"
1061 o : "'entity
1062 value' undefined"
1064 o : "bogus 2068
1065 Date header reference"
1067 C.6. Since draft-ietf-httpbis-p4-conditional-04
1069 Ongoing work on ABNF conversion
1070 ():
1072 o Use "/" instead of "|" for alternatives.
1074 o Introduce new ABNF rules for "bad" whitespace ("BWS"), optional
1075 whitespace ("OWS") and required whitespace ("RWS").
1077 o Rewrite ABNFs to spell out whitespace rules, factor out header
1078 field value format definitions.
1080 C.7. Since draft-ietf-httpbis-p4-conditional-05
1082 Final work on ABNF conversion
1083 ():
1085 o Add appendix containing collected and expanded ABNF, reorganize
1086 ABNF introduction.
1088 C.8. Since draft-ietf-httpbis-p4-conditional-06
1090 Closed issues:
1092 o : "case-
1093 sensitivity of etag weakness indicator"
1095 C.9. Since draft-ietf-httpbis-p4-conditional-07
1097 Closed issues:
1099 o : "Weak ETags on
1100 non-GET requests" (If-Match still was defined to require strong
1101 matching)
1103 o : "move IANA
1104 registrations for optional status codes"
1106 C.10. Since draft-ietf-httpbis-p4-conditional-08
1108 No significant changes.
1110 C.11. Since draft-ietf-httpbis-p4-conditional-09
1112 No significant changes.
1114 C.12. Since draft-ietf-httpbis-p4-conditional-10
1116 Closed issues:
1118 o : "Clarify
1119 'Requested Variant'"
1121 o : "Clarify
1122 entity / representation / variant terminology"
1124 o : "consider
1125 removing the 'changes from 2068' sections"
1127 C.13. Since draft-ietf-httpbis-p4-conditional-11
1129 None.
1131 C.14. Since draft-ietf-httpbis-p4-conditional-12
1133 Closed issues:
1135 o : "Header
1136 Classification"
1138 C.15. Since draft-ietf-httpbis-p4-conditional-13
1140 Closed issues:
1142 o : "If-* and
1143 entities"
1145 o : "Definition of
1146 validator weakness"
1148 o : "untangle
1149 ABNFs for header fields"
1151 o : "ETags and
1152 Quotes"
1154 C.16. Since draft-ietf-httpbis-p4-conditional-14
1156 None.
1158 C.17. Since draft-ietf-httpbis-p4-conditional-15
1160 Closed issues:
1162 o : "If-Range
1163 should be listed when dicussing contexts where L-M can be
1164 considered strong"
1166 C.18. Since draft-ietf-httpbis-p4-conditional-16
1168 Closed issues:
1170 o : "Document
1171 HTTP's error-handling philosophy"
1173 C.19. Since draft-ietf-httpbis-p4-conditional-17
1175 Closed issues:
1177 o : "does etag
1178 value really use quoted-string"
1180 C.20. Since draft-ietf-httpbis-p4-conditional-18
1182 Closed issues:
1184 o : "Required
1185 headers on 304 and 206"
1187 Index
1189 3
1190 304 Not Modified (status code) 18
1192 4
1193 412 Precondition Failed (status code) 19
1195 E
1196 ETag header field 9
1198 G
1199 Grammar
1200 entity-tag 9
1201 ETag 9
1202 etagc 9
1203 If-Match 14
1204 If-Modified-Since 16
1205 If-None-Match 15
1206 If-Unmodified-Since 17
1207 Last-Modified 7
1208 opaque-tag 9
1209 weak 9
1211 H
1212 Header Fields
1213 ETag 9
1214 If-Match 14
1215 If-Modified-Since 16
1216 If-None-Match 15
1217 If-Unmodified-Since 17
1218 Last-Modified 7
1220 I
1221 If-Match header field 14
1222 If-Modified-Since header field 16
1223 If-None-Match header field 15
1224 If-Unmodified-Since header field 17
1226 L
1227 Last-Modified header field 7
1229 M
1230 metadata 5
1232 S
1233 selected representation 4
1234 Status Codes
1235 304 Not Modified 18
1236 412 Precondition Failed 19
1238 V
1239 validator 5
1240 strong 5
1241 weak 5
1243 Authors' Addresses
1245 Roy T. Fielding (editor)
1246 Adobe Systems Incorporated
1247 345 Park Ave
1248 San Jose, CA 95110
1249 USA
1251 EMail: fielding@gbiv.com
1252 URI: http://roy.gbiv.com/
1254 Yves Lafon (editor)
1255 World Wide Web Consortium
1256 W3C / ERCIM
1257 2004, rte des Lucioles
1258 Sophia-Antipolis, AM 06902
1259 France
1261 EMail: ylafon@w3.org
1262 URI: http://www.raubacapeu.net/people/yves/
1263 Julian F. Reschke (editor)
1264 greenbytes GmbH
1265 Hafenweg 16
1266 Muenster, NW 48155
1267 Germany
1269 Phone: +49 251 2807760
1270 Fax: +49 251 2807761
1271 EMail: julian.reschke@greenbytes.de
1272 URI: http://greenbytes.de/tech/webdav/