idnits 2.17.1 draft-ietf-httpbis-p4-conditional-16.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 (August 24, 2011) is 4622 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-16 == Outdated reference: A later version (-20) exists of draft-ietf-httpbis-p3-payload-16 == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p5-range-16 == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p6-cache-16 -- 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 (==), 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) J. Gettys 5 Intended status: Standards Track Alcatel-Lucent 6 Expires: February 25, 2012 J. Mogul 7 HP 8 H. Frystyk 9 Microsoft 10 L. Masinter 11 Adobe 12 P. Leach 13 Microsoft 14 T. Berners-Lee 15 W3C/MIT 16 Y. Lafon, Ed. 17 W3C 18 J. Reschke, Ed. 19 greenbytes 20 August 24, 2011 22 HTTP/1.1, part 4: Conditional Requests 23 draft-ietf-httpbis-p4-conditional-16 25 Abstract 27 The Hypertext Transfer Protocol (HTTP) is an application-level 28 protocol for distributed, collaborative, hypertext information 29 systems. HTTP has been in use by the World Wide Web global 30 information initiative since 1990. This document is Part 4 of the 31 seven-part specification that defines the protocol referred to as 32 "HTTP/1.1" and, taken together, obsoletes RFC 2616. 34 Part 4 defines request header fields for indicating conditional 35 requests and the rules for constructing responses to those requests. 37 Editorial Note (To be removed by RFC Editor) 39 Discussion of this draft should take place on the HTTPBIS working 40 group mailing list (ietf-http-wg@w3.org), which is archived at 41 . 43 The current issues list is at 44 and related 45 documents (including fancy diffs) can be found at 46 . 48 The changes in this draft are summarized in Appendix C.17. 50 Status of This Memo 52 This Internet-Draft is submitted in full conformance with the 53 provisions of BCP 78 and BCP 79. 55 Internet-Drafts are working documents of the Internet Engineering 56 Task Force (IETF). Note that other groups may also distribute 57 working documents as Internet-Drafts. The list of current Internet- 58 Drafts is at http://datatracker.ietf.org/drafts/current/. 60 Internet-Drafts are draft documents valid for a maximum of six months 61 and may be updated, replaced, or obsoleted by other documents at any 62 time. It is inappropriate to use Internet-Drafts as reference 63 material or to cite them other than as "work in progress." 65 This Internet-Draft will expire on February 25, 2012. 67 Copyright Notice 69 Copyright (c) 2011 IETF Trust and the persons identified as the 70 document authors. All rights reserved. 72 This document is subject to BCP 78 and the IETF Trust's Legal 73 Provisions Relating to IETF Documents 74 (http://trustee.ietf.org/license-info) in effect on the date of 75 publication of this document. Please review these documents 76 carefully, as they describe your rights and restrictions with respect 77 to this document. Code Components extracted from this document must 78 include Simplified BSD License text as described in Section 4.e of 79 the Trust Legal Provisions and are provided without warranty as 80 described in the Simplified BSD License. 82 This document may contain material from IETF Documents or IETF 83 Contributions published or made publicly available before November 84 10, 2008. The person(s) controlling the copyright in some of this 85 material may not have granted the IETF Trust the right to allow 86 modifications of such material outside the IETF Standards Process. 87 Without obtaining an adequate license from the person(s) controlling 88 the copyright in such materials, this document may not be modified 89 outside the IETF Standards Process, and derivative works of it may 90 not be created outside the IETF Standards Process, except to format 91 it for publication as an RFC or to translate it into languages other 92 than English. 94 Table of Contents 96 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5 97 1.1. Requirements . . . . . . . . . . . . . . . . . . . . . . . 5 98 1.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 6 99 2. Validators . . . . . . . . . . . . . . . . . . . . . . . . . . 6 100 2.1. Weak versus Strong . . . . . . . . . . . . . . . . . . . . 6 101 2.2. Last-Modified . . . . . . . . . . . . . . . . . . . . . . 8 102 2.2.1. Generation . . . . . . . . . . . . . . . . . . . . . . 8 103 2.2.2. Comparison . . . . . . . . . . . . . . . . . . . . . . 9 104 2.3. ETag . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 105 2.3.1. Generation . . . . . . . . . . . . . . . . . . . . . . 11 106 2.3.2. Comparison . . . . . . . . . . . . . . . . . . . . . . 11 107 2.3.3. Example: Entity-tags varying on Content-Negotiated 108 Resources . . . . . . . . . . . . . . . . . . . . . . 12 109 2.4. Rules for When to Use Entity-tags and Last-Modified 110 Dates . . . . . . . . . . . . . . . . . . . . . . . . . . 13 111 3. Precondition Header Fields . . . . . . . . . . . . . . . . . . 14 112 3.1. If-Match . . . . . . . . . . . . . . . . . . . . . . . . . 14 113 3.2. If-None-Match . . . . . . . . . . . . . . . . . . . . . . 15 114 3.3. If-Modified-Since . . . . . . . . . . . . . . . . . . . . 17 115 3.4. If-Unmodified-Since . . . . . . . . . . . . . . . . . . . 18 116 3.5. If-Range . . . . . . . . . . . . . . . . . . . . . . . . . 19 117 4. Status Code Definitions . . . . . . . . . . . . . . . . . . . 19 118 4.1. 304 Not Modified . . . . . . . . . . . . . . . . . . . . . 19 119 4.2. 412 Precondition Failed . . . . . . . . . . . . . . . . . 20 120 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 20 121 5.1. Status Code Registration . . . . . . . . . . . . . . . . . 20 122 5.2. Header Field Registration . . . . . . . . . . . . . . . . 20 123 6. Security Considerations . . . . . . . . . . . . . . . . . . . 20 124 7. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 21 125 8. References . . . . . . . . . . . . . . . . . . . . . . . . . . 21 126 8.1. Normative References . . . . . . . . . . . . . . . . . . . 21 127 8.2. Informative References . . . . . . . . . . . . . . . . . . 21 128 Appendix A. Changes from RFC 2616 . . . . . . . . . . . . . . . . 22 129 Appendix B. Collected ABNF . . . . . . . . . . . . . . . . . . . 22 130 Appendix C. Change Log (to be removed by RFC Editor before 131 publication) . . . . . . . . . . . . . . . . . . . . 23 132 C.1. Since RFC 2616 . . . . . . . . . . . . . . . . . . . . . . 23 133 C.2. Since draft-ietf-httpbis-p4-conditional-00 . . . . . . . . 23 134 C.3. Since draft-ietf-httpbis-p4-conditional-01 . . . . . . . . 23 135 C.4. Since draft-ietf-httpbis-p4-conditional-02 . . . . . . . . 23 136 C.5. Since draft-ietf-httpbis-p4-conditional-03 . . . . . . . . 23 137 C.6. Since draft-ietf-httpbis-p4-conditional-04 . . . . . . . . 24 138 C.7. Since draft-ietf-httpbis-p4-conditional-05 . . . . . . . . 24 139 C.8. Since draft-ietf-httpbis-p4-conditional-06 . . . . . . . . 24 140 C.9. Since draft-ietf-httpbis-p4-conditional-07 . . . . . . . . 24 141 C.10. Since draft-ietf-httpbis-p4-conditional-08 . . . . . . . . 24 142 C.11. Since draft-ietf-httpbis-p4-conditional-09 . . . . . . . . 25 143 C.12. Since draft-ietf-httpbis-p4-conditional-10 . . . . . . . . 25 144 C.13. Since draft-ietf-httpbis-p4-conditional-11 . . . . . . . . 25 145 C.14. Since draft-ietf-httpbis-p4-conditional-12 . . . . . . . . 25 146 C.15. Since draft-ietf-httpbis-p4-conditional-13 . . . . . . . . 25 147 C.16. Since draft-ietf-httpbis-p4-conditional-14 . . . . . . . . 26 148 C.17. Since draft-ietf-httpbis-p4-conditional-15 . . . . . . . . 26 149 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 151 1. Introduction 153 This document defines the HTTP/1.1 conditional request mechanisms, 154 including both metadata for indicating/observing changes in resource 155 representations and request header fields that specify preconditions 156 on that metadata be checked before performing the request method. 157 Conditional GET requests are the most efficient mechanism for HTTP 158 cache updates [Part6]. Conditionals can also be applied to state- 159 changing methods, such as PUT and DELETE, to prevent the "lost 160 update" problem: one client accidentally overwriting the work of 161 another client that has been acting in parallel. 163 Conditional request preconditions are based on the state of the 164 target resource as a whole (its current value set) or the state as 165 observed in a previously obtained representation (one value in that 166 set). A resource might have multiple current representations, each 167 with its own observable state. The conditional request mechanisms 168 assume that the mapping of requests to corresponding representations 169 will be consistent over time if the server intends to take advantage 170 of conditionals. Regardless, if the mapping is inconsistent and the 171 server is unable to select the appropriate representation, then no 172 harm will result when the precondition evaluates to false. 174 We use the term "selected representation" to refer to the current 175 representation of the target resource that would have been selected 176 in a successful response if the same request had used the method GET 177 and had excluded all of the conditional request header fields. The 178 conditional request preconditions are evaluated by comparing the 179 values provided in the request header fields to the current metadata 180 for the selected representation. 182 1.1. Requirements 184 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 185 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 186 document are to be interpreted as described in [RFC2119]. 188 An implementation is not compliant if it fails to satisfy one or more 189 of the "MUST" or "REQUIRED" level requirements for the protocols it 190 implements. An implementation that satisfies all the "MUST" or 191 "REQUIRED" level and all the "SHOULD" level requirements for its 192 protocols is said to be "unconditionally compliant"; one that 193 satisfies all the "MUST" level requirements but not all the "SHOULD" 194 level requirements for its protocols is said to be "conditionally 195 compliant". 197 1.2. Syntax Notation 199 This specification uses the ABNF syntax defined in Section 1.2 of 200 [Part1] (which extends the syntax defined in [RFC5234] with a list 201 rule). Appendix B shows the collected ABNF, with the list rule 202 expanded. 204 The following core rules are included by reference, as defined in 205 [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF 206 (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote), 207 HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed), OCTET (any 8-bit 208 sequence of data), SP (space), VCHAR (any visible USASCII character), 209 and WSP (whitespace). 211 The ABNF rules below are defined in [Part1]: 213 OWS = 214 quoted-string = 215 HTTP-date = 217 2. Validators 219 This specification defines two forms of metadata that are commonly 220 used to observe resource state and test for preconditions: 221 modification dates and opaque entity tags. Additional metadata that 222 reflects resource state has been defined by various extensions of 223 HTTP, such as WebDAV [RFC4918], that are beyond the scope of this 224 specification. A resource metadata value is referred to as a 225 "validator" when it is used within a precondition. 227 2.1. Weak versus Strong 229 Validators come in two flavors: strong or weak. Weak validators are 230 easy to generate but are far less useful for comparisons. Strong 231 validators are ideal for comparisons but can be very difficult (and 232 occasionally impossible) to generate efficiently. Rather than impose 233 that all forms of resource adhere to the same strength of validator, 234 HTTP exposes the type of validator in use and imposes restrictions on 235 when weak validators can be used as preconditions. 237 A "strong validator" is a representation metadata value that MUST be 238 changed to a new, previously unused or guaranteed unique, value 239 whenever a change occurs to the representation data such that a 240 change would be observable in the payload body of a 200 response to 241 GET. A strong validator MAY be changed for other reasons, such as 242 when a semantically significant part of the representation metadata 243 is changed (e.g., Content-Type), but it is in the best interests of 244 the origin server to only change the value when it is necessary to 245 invalidate the stored responses held by remote caches and authoring 246 tools. A strong validator MUST be unique across all representations 247 of a given resource, such that no two representations of that 248 resource share the same validator unless their payload body would be 249 identical. 251 Cache entries might persist for arbitrarily long periods, regardless 252 of expiration times. Thus, a cache might attempt to validate an 253 entry using a validator that it obtained in the distant past. A 254 strong validator MUST be unique across all versions of all 255 representations associated with a particular resource over time. 256 However, there is no implication of uniqueness across representations 257 of different resources (i.e., the same strong validator might be in 258 use for representations of multiple resources at the same time and 259 does not imply that those representations are equivalent). 261 There are a variety of strong validators used in practice. The best 262 are based on strict revision control, wherein each change to a 263 representation always results in a unique node name and revision 264 identifier being assigned before the representation is made 265 accessible to GET. A cryptographic hash function applied to the 266 representation data is also sufficient if the data is available prior 267 to the response header fields being sent and the digest does not need 268 to be recalculated every time a validation request is received. 269 However, if a resource has distinct representations that differ only 270 in their metadata, such as might occur with content negotiation over 271 media types that happen to share the same data format, then a server 272 SHOULD incorporate additional information in the validator to 273 distinguish those representations and avoid confusing cache behavior. 275 In contrast, a "weak validator" is a representation metadata value 276 that might not be changed for every change to the representation 277 data. This weakness might be due to limitations in how the value is 278 calculated, such as clock resolution or an inability to ensure 279 uniqueness for all possible representations of the resource, or due 280 to a desire by the resource owner to group representations by some 281 self-determined set of equivalency rather than unique sequences of 282 data. A weak entity-tag SHOULD change whenever the origin server 283 considers prior representations to be unacceptable as a substitute 284 for the current representation. In other words, a weak entity-tag 285 SHOULD change whenever the origin server wants caches to invalidate 286 old responses. 288 For example, the representation of a weather report that changes in 289 content every second, based on dynamic measurements, might be grouped 290 into sets of equivalent representations (from the origin server's 291 perspective) with the same weak validator in order to allow cached 292 representations to be valid for a reasonable period of time (perhaps 293 adjusted dynamically based on server load or weather quality). 294 Likewise, a representation's modification time, if defined with only 295 one-second resolution, might be a weak validator if it is possible 296 for the representation to be modified twice during a single second 297 and retrieved between those modifications. 299 A "use" of a validator occurs when either a client generates a 300 request and includes the validator in a precondition or when a server 301 compares two validators. Weak validators are only usable in contexts 302 that do not depend on exact equality of a representation's payload 303 body. Strong validators are usable and preferred for all conditional 304 requests, including cache validation, partial content ranges, and 305 "lost update" avoidance. 307 2.2. Last-Modified 309 The "Last-Modified" header field indicates the date and time at which 310 the origin server believes the selected representation was last 311 modified. 313 Last-Modified = HTTP-date 315 An example of its use is 317 Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT 319 2.2.1. Generation 321 Origin servers SHOULD send Last-Modified for any selected 322 representation for which a last modification date can be reasonably 323 and consistently determined, since its use in conditional requests 324 and evaluating cache freshness ([Part6]) results in a substantial 325 reduction of HTTP traffic on the Internet and can be a significant 326 factor in improving service scalability and reliability. 328 A representation is typically the sum of many parts behind the 329 resource interface. The last-modified time would usually be the most 330 recent time that any of those parts were changed. How that value is 331 determined for any given resource is an implementation detail beyond 332 the scope of this specification. What matters to HTTP is how 333 recipients of the Last-Modified header field can use its value to 334 make conditional requests and test the validity of locally cached 335 responses. 337 An origin server SHOULD obtain the Last-Modified value of the 338 representation as close as possible to the time that it generates the 339 Date field-value for its response. This allows a recipient to make 340 an accurate assessment of the representation's modification time, 341 especially if the representation changes near the time that the 342 response is generated. 344 An origin server with a clock MUST NOT send a Last-Modified date that 345 is later than the server's time of message origination (Date). If 346 the last modification time is derived from implementation-specific 347 metadata that evaluates to some time in the future, according to the 348 origin server's clock, then the origin server MUST replace that value 349 with the message origination date. This prevents a future 350 modification date from having an adverse impact on cache validation. 352 2.2.2. Comparison 354 A Last-Modified time, when used as a validator in a request, is 355 implicitly weak unless it is possible to deduce that it is strong, 356 using the following rules: 358 o The validator is being compared by an origin server to the actual 359 current validator for the representation and, 361 o That origin server reliably knows that the associated 362 representation did not change twice during the second covered by 363 the presented validator. 365 or 367 o The validator is about to be used by a client in an If-Modified- 368 Since, If-Unmodified-Since header field, because the client has a 369 cache entry, or If-Range for the associated representation, and 371 o That cache entry includes a Date value, which gives the time when 372 the origin server sent the original response, and 374 o The presented Last-Modified time is at least 60 seconds before the 375 Date value. 377 or 379 o The validator is being compared by an intermediate cache to the 380 validator stored in its cache entry for the 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 This method relies on the fact that if two different responses were 389 sent by the origin server during the same second, but both had the 390 same Last-Modified time, then at least one of those responses would 391 have a Date value equal to its Last-Modified time. The arbitrary 60- 392 second limit guards against the possibility that the Date and Last- 393 Modified values are generated from different clocks, or at somewhat 394 different times during the preparation of the response. An 395 implementation MAY use a value larger than 60 seconds, if it is 396 believed that 60 seconds is too short. 398 2.3. ETag 400 The ETag header field provides the current entity-tag for the 401 selected representation. An entity-tag is an opaque validator for 402 differentiating between multiple representations of the same 403 resource, regardless of whether those multiple representations are 404 due to resource state changes over time, content negotiation 405 resulting in multiple representations being valid at the same time, 406 or both. An entity-tag consists of an opaque quoted string, possibly 407 prefixed by a weakness indicator. 409 ETag = entity-tag 411 entity-tag = [ weak ] opaque-tag 412 weak = %x57.2F ; "W/", case-sensitive 413 opaque-tag = quoted-string 415 An entity-tag can be more reliable for validation than a modification 416 date in situations where it is inconvenient to store modification 417 dates, where the one-second resolution of HTTP date values is not 418 sufficient, or where modification dates are not consistently 419 maintained. 421 Examples: 423 ETag: "xyzzy" 424 ETag: W/"xyzzy" 425 ETag: "" 427 An entity-tag can be either a weak or strong validator, with strong 428 being the default. If an origin server provides an entity-tag for a 429 representation and the generation of that entity-tag does not satisfy 430 the requirements for a strong validator (Section 2.1), then that 431 entity-tag MUST be marked as weak by prefixing its opaque value with 432 "W/" (case-sensitive). 434 2.3.1. Generation 436 The principle behind entity-tags is that only the service author 437 knows the implementation of a resource well enough to select the most 438 accurate and efficient validation mechanism for that resource, and 439 that any such mechanism can be mapped to a simple sequence of octets 440 for easy comparison. Since the value is opaque, there is no need for 441 the client to be aware of how each entity-tag is constructed. 443 For example, a resource that has implementation-specific versioning 444 applied to all changes might use an internal revision number, perhaps 445 combined with a variance identifier for content negotiation, to 446 accurately differentiate between representations. Other 447 implementations might use a stored hash of representation content, a 448 combination of various filesystem attributes, or a modification 449 timestamp that has sub-second resolution. 451 Origin servers SHOULD send ETag for any selected representation for 452 which detection of changes can be reasonably and consistently 453 determined, since the entity-tag's use in conditional requests and 454 evaluating cache freshness ([Part6]) can result in a substantial 455 reduction of HTTP network traffic and can be a significant factor in 456 improving service scalability and reliability. 458 2.3.2. Comparison 460 There are two entity-tag comparison functions, depending on whether 461 the comparison context allows the use of weak validators or not: 463 o The strong comparison function: in order to be considered equal, 464 both opaque-tags MUST be identical character-by-character, and 465 both MUST NOT be weak. 467 o The weak comparison function: in order to be considered equal, 468 both opaque-tags MUST be identical character-by-character, but 469 either or both of them MAY be tagged as "weak" without affecting 470 the result. 472 The example below shows the results for a set of entity-tag pairs, 473 and both the weak and strong comparison function results: 475 +--------+--------+-------------------+-----------------+ 476 | ETag 1 | ETag 2 | Strong Comparison | Weak Comparison | 477 +--------+--------+-------------------+-----------------+ 478 | W/"1" | W/"1" | no match | match | 479 | W/"1" | W/"2" | no match | no match | 480 | W/"1" | "1" | no match | match | 481 | "1" | "1" | match | match | 482 +--------+--------+-------------------+-----------------+ 484 2.3.3. Example: Entity-tags varying on Content-Negotiated Resources 486 Consider a resource that is subject to content negotiation (Section 5 487 of [Part3]), and where the representations returned upon a GET 488 request vary based on the Accept-Encoding request header field 489 (Section 6.3 of [Part3]): 491 >> Request: 493 GET /index HTTP/1.1 494 Host: www.example.com 495 Accept-Encoding: gzip 497 In this case, the response might or might not use the gzip content 498 coding. If it does not, the response might look like: 500 >> Response: 502 HTTP/1.1 200 OK 503 Date: Thu, 26 Mar 2010 00:05:00 GMT 504 ETag: "123-a" 505 Content-Length: 70 506 Vary: Accept-Encoding 507 Content-Type: text/plain 509 Hello World! 510 Hello World! 511 Hello World! 512 Hello World! 513 Hello World! 515 An alternative representation that does use gzip content coding would 516 be: 518 >> Response: 520 HTTP/1.1 200 OK 521 Date: Thu, 26 Mar 2010 00:05:00 GMT 522 ETag: "123-b" 523 Content-Length: 43 524 Vary: Accept-Encoding 525 Content-Type: text/plain 526 Content-Encoding: gzip 528 ...binary data... 530 Note: Content codings are a property of the representation, so 531 therefore an entity-tag of an encoded representation must be 532 distinct from an unencoded representation to prevent conflicts 533 during cache updates and range requests. In contrast, transfer 534 codings (Section 6.2 of [Part1]) apply only during message 535 transfer and do not require distinct entity-tags. 537 2.4. Rules for When to Use Entity-tags and Last-Modified Dates 539 We adopt a set of rules and recommendations for origin servers, 540 clients, and caches regarding when various validator types ought to 541 be used, and for what purposes. 543 HTTP/1.1 origin servers: 545 o SHOULD send an entity-tag validator unless it is not feasible to 546 generate one. 548 o MAY send a weak entity-tag instead of a strong entity-tag, if 549 performance considerations support the use of weak entity-tags, or 550 if it is unfeasible to send a strong entity-tag. 552 o SHOULD send a Last-Modified value if it is feasible to send one. 554 In other words, the preferred behavior for an HTTP/1.1 origin server 555 is to send both a strong entity-tag and a Last-Modified value. 557 HTTP/1.1 clients: 559 o MUST use that entity-tag in any cache-conditional request (using 560 If-Match or If-None-Match) if an entity-tag has been provided by 561 the origin server. 563 o SHOULD use the Last-Modified value in non-subrange cache- 564 conditional requests (using If-Modified-Since) if only a Last- 565 Modified value has been provided by the origin server. 567 o MAY use the Last-Modified value in subrange cache-conditional 568 requests (using If-Unmodified-Since) if only a Last-Modified value 569 has been provided by an HTTP/1.0 origin server. The user agent 570 SHOULD provide a way to disable this, in case of difficulty. 572 o SHOULD use both validators in cache-conditional requests if both 573 an entity-tag and a Last-Modified value have been provided by the 574 origin server. This allows both HTTP/1.0 and HTTP/1.1 caches to 575 respond appropriately. 577 An HTTP/1.1 origin server, upon receiving a conditional request that 578 includes both a Last-Modified date (e.g., in an If-Modified-Since or 579 If-Unmodified-Since header field) and one or more entity-tags (e.g., 580 in an If-Match, If-None-Match, or If-Range header field) as cache 581 validators, MUST NOT return a response status code of 304 (Not 582 Modified) unless doing so is consistent with all of the conditional 583 header fields in the request. 585 An HTTP/1.1 caching proxy, upon receiving a conditional request that 586 includes both a Last-Modified date and one or more entity-tags as 587 cache validators, MUST NOT return a locally cached response to the 588 client unless that cached response is consistent with all of the 589 conditional header fields in the request. 591 Note: The general principle behind these rules is that HTTP/1.1 592 servers and clients ought to transmit as much non-redundant 593 information as is available in their responses and requests. 594 HTTP/1.1 systems receiving this information will make the most 595 conservative assumptions about the validators they receive. 597 HTTP/1.0 clients and caches might ignore entity-tags. Generally, 598 last-modified values received or used by these systems will 599 support transparent and efficient caching, and so HTTP/1.1 origin 600 servers should provide Last-Modified values. In those rare cases 601 where the use of a Last-Modified value as a validator by an 602 HTTP/1.0 system could result in a serious problem, then HTTP/1.1 603 origin servers should not provide one. 605 3. Precondition Header Fields 607 This section defines the syntax and semantics of HTTP/1.1 header 608 fields for applying preconditions on requests. 610 3.1. If-Match 612 The "If-Match" header field MAY be used to make a request method 613 conditional on the current existence or value of an entity-tag for 614 one or more representations of the target resource. If-Match is 615 generally useful for resource update requests, such as PUT requests, 616 as a means for protecting against accidental overwrites when multiple 617 clients are acting in parallel on the same resource (i.e., the "lost 618 update" problem). An If-Match field-value of "*" places the 619 precondition on the existence of any current representation for the 620 target resource. 622 If-Match = "*" / 1#entity-tag 624 If any of the entity-tags listed in the If-Match field value match 625 (as per Section 2.3.2) the entity-tag of the selected representation 626 for the target resource, or if "*" is given and any current 627 representation exists for the target resource, then the server MAY 628 perform the request method as if the If-Match header field was not 629 present. 631 If none of the entity-tags match, or if "*" is given and no current 632 representation exists, the server MUST NOT perform the requested 633 method. Instead, the server MUST respond with the 412 (Precondition 634 Failed) status code. 636 If the request would, without the If-Match header field, result in 637 anything other than a 2xx or 412 status code, then the If-Match 638 header field MUST be ignored. 640 Examples: 642 If-Match: "xyzzy" 643 If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz" 644 If-Match: * 646 The result of a request having both an If-Match header field and 647 either an If-None-Match or an If-Modified-Since header fields is 648 undefined by this specification. 650 3.2. If-None-Match 652 The "If-None-Match" header field MAY be used to make a request method 653 conditional on not matching any of the current entity-tag values for 654 representations of the target resource. If-None-Match is primarily 655 used in conditional GET requests to enable efficient updates of 656 cached information with a minimum amount of transaction overhead. A 657 client that has one or more representations previously obtained from 658 the target resource can send If-None-Match with a list of the 659 associated entity-tags in the hope of receiving a 304 response if at 660 least one of those representations matches the selected 661 representation. 663 If-None-Match MAY also be used with a value of "*" to prevent an 664 unsafe request method (e.g., PUT) from inadvertently modifying an 665 existing representation of the target resource when the client 666 believes that the resource does not have a current representation. 667 This is a variation on the "lost update" problem that might arise if 668 more than one client attempts to create an initial representation for 669 the target resource. 671 If-None-Match = "*" / 1#entity-tag 673 If any of the entity-tags listed in the If-None-Match field-value 674 match (as per Section 2.3.2) the entity-tag of the selected 675 representation, or if "*" is given and any current representation 676 exists for that resource, then the server MUST NOT perform the 677 requested method. Instead, if the request method was GET or HEAD, 678 the server SHOULD respond with a 304 (Not Modified) status code, 679 including the cache-related header fields (particularly ETag) of the 680 selected representation that has a matching entity-tag. For all 681 other request methods, the server MUST respond with a 412 682 (Precondition Failed) status code. 684 If none of the entity-tags match, then the server MAY perform the 685 requested method as if the If-None-Match header field did not exist, 686 but MUST also ignore any If-Modified-Since header field(s) in the 687 request. That is, if no entity-tags match, then the server MUST NOT 688 return a 304 (Not Modified) response. 690 If the request would, without the If-None-Match header field, result 691 in anything other than a 2xx or 304 status code, then the If-None- 692 Match header field MUST be ignored. (See Section 2.4 for a 693 discussion of server behavior when both If-Modified-Since and If- 694 None-Match appear in the same request.) 696 Examples: 698 If-None-Match: "xyzzy" 699 If-None-Match: W/"xyzzy" 700 If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz" 701 If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz" 702 If-None-Match: * 704 The result of a request having both an If-None-Match header field and 705 either an If-Match or an If-Unmodified-Since header fields is 706 undefined by this specification. 708 3.3. If-Modified-Since 710 The "If-Modified-Since" header field MAY be used to make a request 711 method conditional by modification date: if the selected 712 representation has not been modified since the time specified in this 713 field, then do not perform the request method; instead, respond as 714 detailed below. 716 If-Modified-Since = HTTP-date 718 An example of the field is: 720 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT 722 A GET method with an If-Modified-Since header field and no Range 723 header field requests that the selected representation be transferred 724 only if it has been modified since the date given by the If-Modified- 725 Since header field. The algorithm for determining this includes the 726 following cases: 728 1. If the request would normally result in anything other than a 200 729 (OK) status code, or if the passed If-Modified-Since date is 730 invalid, the response is exactly the same as for a normal GET. A 731 date which is later than the server's current time is invalid. 733 2. If the selected representation has been modified since the If- 734 Modified-Since date, the response is exactly the same as for a 735 normal GET. 737 3. If the selected representation has not been modified since a 738 valid If-Modified-Since date, the server SHOULD return a 304 (Not 739 Modified) response. 741 The purpose of this feature is to allow efficient updates of cached 742 information with a minimum amount of transaction overhead. 744 Note: The Range header field modifies the meaning of If-Modified- 745 Since; see Section 5.4 of [Part5] for full details. 747 Note: If-Modified-Since times are interpreted by the server, whose 748 clock might not be synchronized with the client. 750 Note: When handling an If-Modified-Since header field, some 751 servers will use an exact date comparison function, rather than a 752 less-than function, for deciding whether to send a 304 (Not 753 Modified) response. To get best results when sending an If- 754 Modified-Since header field for cache validation, clients are 755 advised to use the exact date string received in a previous Last- 756 Modified header field whenever possible. 758 Note: If a client uses an arbitrary date in the If-Modified-Since 759 header field instead of a date taken from the Last-Modified header 760 field for the same request, the client needs to be aware that this 761 date is interpreted in the server's understanding of time. 762 Unsynchronized clocks and rounding problems, due to the different 763 encodings of time between the client and server, are concerns. 764 This includes the possibility of race conditions if the document 765 has changed between the time it was first requested and the If- 766 Modified-Since date of a subsequent request, and the possibility 767 of clock-skew-related problems if the If-Modified-Since date is 768 derived from the client's clock without correction to the server's 769 clock. Corrections for different time bases between client and 770 server are at best approximate due to network latency. 772 The result of a request having both an If-Modified-Since header field 773 and either an If-Match or an If-Unmodified-Since header fields is 774 undefined by this specification. 776 3.4. If-Unmodified-Since 778 The "If-Unmodified-Since" header field MAY be used to make a request 779 method conditional by modification date: if the selected 780 representation has been modified since the time specified in this 781 field, then the server MUST NOT perform the requested operation and 782 MUST instead respond with the 412 (Precondition Failed) status code. 783 If the selected representation has not been modified since the time 784 specified in this field, the server SHOULD perform the request method 785 as if the If-Unmodified-Since header field were not present. 787 If-Unmodified-Since = HTTP-date 789 An example of the field is: 791 If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT 793 If the request normally (i.e., without the If-Unmodified-Since header 794 field) would result in anything other than a 2xx or 412 status code, 795 the If-Unmodified-Since header field SHOULD be ignored. 797 If the specified date is invalid, the header field MUST be ignored. 799 The result of a request having both an If-Unmodified-Since header 800 field and either an If-None-Match or an If-Modified-Since header 801 fields is undefined by this specification. 803 3.5. If-Range 805 The If-Range header field provides a special conditional request 806 mechanism that is similar to If-Match and If-Unmodified-Since but 807 specific to HTTP range requests. If-Range is defined in Section 5.3 808 of [Part5]. 810 4. Status Code Definitions 812 4.1. 304 Not Modified 814 The 304 status code indicates that a conditional GET request has been 815 received and would have resulted in a 200 (OK) response if it were 816 not for the fact that the condition has evaluated to false. In other 817 words, there is no need for the server to transfer a representation 818 of the target resource because the client's request indicates that it 819 already has a valid representation, as indicated by the 304 response 820 header fields, and is therefore redirecting the client to make use of 821 that stored representation as if it were the payload of a 200 822 response. The 304 response MUST NOT contain a message-body, and thus 823 is always terminated by the first empty line after the header fields. 825 A 304 response MUST include a Date header field (Section 9.3 of 826 [Part1]) unless its omission is required by Section 9.3.1 of [Part1]. 827 If a 200 response to the same request would have included any of the 828 header fields Cache-Control, Content-Location, ETag, Expires, Last- 829 Modified, or Vary, then those same header fields MUST be sent in a 830 304 response. 832 Since the goal of a 304 response is to minimize information transfer 833 when the recipient already has one or more cached representations, 834 the response SHOULD NOT include representation metadata other than 835 the above listed fields unless said metadata exists for the purpose 836 of guiding cache updates (e.g., future HTTP extensions). 838 If the recipient of a 304 response does not have a cached 839 representation corresponding to the entity-tag indicated by the 304 840 response, then the recipient MUST NOT use the 304 to update its own 841 cache. If this conditional request originated with an outbound 842 client, such as a user agent with its own cache sending a conditional 843 GET to a shared proxy, then the 304 response MAY be forwarded to the 844 outbound client. Otherwise, the recipient MUST disregard the 304 845 response and repeat the request without any preconditions. 847 If a cache uses a received 304 response to update a cache entry, the 848 cache MUST update the entry to reflect any new field values given in 849 the response. 851 4.2. 412 Precondition Failed 853 The 412 status code indicates that one or more preconditions given in 854 the request header fields evaluated to false when tested on the 855 server. This response code allows the client to place preconditions 856 on the current resource state (its current representations and 857 metadata) and thus prevent the request method from being applied if 858 the target resource is in an unexpected state. 860 5. IANA Considerations 862 5.1. Status Code Registration 864 The HTTP Status Code Registry located at 865 shall be updated 866 with the registrations below: 868 +-------+---------------------+-------------+ 869 | Value | Description | Reference | 870 +-------+---------------------+-------------+ 871 | 304 | Not Modified | Section 4.1 | 872 | 412 | Precondition Failed | Section 4.2 | 873 +-------+---------------------+-------------+ 875 5.2. Header Field Registration 877 The Message Header Field Registry located at shall be 879 updated with the permanent registrations below (see [RFC3864]): 881 +---------------------+----------+----------+-------------+ 882 | Header Field Name | Protocol | Status | Reference | 883 +---------------------+----------+----------+-------------+ 884 | ETag | http | standard | Section 2.3 | 885 | If-Match | http | standard | Section 3.1 | 886 | If-Modified-Since | http | standard | Section 3.3 | 887 | If-None-Match | http | standard | Section 3.2 | 888 | If-Unmodified-Since | http | standard | Section 3.4 | 889 | Last-Modified | http | standard | Section 2.2 | 890 +---------------------+----------+----------+-------------+ 892 The change controller is: "IETF (iesg@ietf.org) - Internet 893 Engineering Task Force". 895 6. Security Considerations 897 No additional security considerations have been identified beyond 898 those applicable to HTTP in general [Part1]. 900 7. Acknowledgments 902 See Section 12 of [Part1]. 904 8. References 906 8.1. Normative References 908 [Part1] Fielding, R., Ed., Gettys, J., Mogul, J., Frystyk, H., 909 Masinter, L., Leach, P., Berners-Lee, T., Lafon, Y., Ed., 910 and J. Reschke, Ed., "HTTP/1.1, part 1: URIs, Connections, 911 and Message Parsing", draft-ietf-httpbis-p1-messaging-16 912 (work in progress), August 2011. 914 [Part3] Fielding, R., Ed., Gettys, J., Mogul, J., Frystyk, H., 915 Masinter, L., Leach, P., Berners-Lee, T., Lafon, Y., Ed., 916 and J. Reschke, Ed., "HTTP/1.1, part 3: Message Payload 917 and Content Negotiation", draft-ietf-httpbis-p3-payload-16 918 (work in progress), August 2011. 920 [Part5] Fielding, R., Ed., Gettys, J., Mogul, J., Frystyk, H., 921 Masinter, L., Leach, P., Berners-Lee, T., Lafon, Y., Ed., 922 and J. Reschke, Ed., "HTTP/1.1, part 5: Range Requests and 923 Partial Responses", draft-ietf-httpbis-p5-range-16 (work 924 in progress), August 2011. 926 [Part6] Fielding, R., Ed., Gettys, J., Mogul, J., Frystyk, H., 927 Masinter, L., Leach, P., Berners-Lee, T., Lafon, Y., Ed., 928 Nottingham, M., Ed., and J. Reschke, Ed., "HTTP/1.1, part 929 6: Caching", draft-ietf-httpbis-p6-cache-16 (work in 930 progress), August 2011. 932 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 933 Requirement Levels", BCP 14, RFC 2119, March 1997. 935 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 936 Specifications: ABNF", STD 68, RFC 5234, January 2008. 938 8.2. Informative References 940 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 941 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 942 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 944 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration 945 Procedures for Message Header Fields", BCP 90, RFC 3864, 946 September 2004. 948 [RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed 949 Authoring and Versioning (WebDAV)", RFC 4918, June 2007. 951 Appendix A. Changes from RFC 2616 953 Allow weak entity-tags in all requests except range requests 954 (Sections 2.1 and 3.2). 956 Change ABNF productions for header fields to only define the field 957 value. (Section 3) 959 Appendix B. Collected ABNF 961 ETag = entity-tag 963 HTTP-date = 965 If-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS 966 entity-tag ] ) ) 967 If-Modified-Since = HTTP-date 968 If-None-Match = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS 969 entity-tag ] ) ) 970 If-Unmodified-Since = HTTP-date 972 Last-Modified = HTTP-date 974 OWS = 976 entity-tag = [ weak ] opaque-tag 978 opaque-tag = quoted-string 980 quoted-string = 982 weak = %x57.2F ; W/ 984 ABNF diagnostics: 986 ; ETag defined but not used 987 ; If-Match defined but not used 988 ; If-Modified-Since defined but not used 989 ; If-None-Match defined but not used 990 ; If-Unmodified-Since defined but not used 991 ; Last-Modified defined but not used 993 Appendix C. Change Log (to be removed by RFC Editor before publication) 995 C.1. Since RFC 2616 997 Extracted relevant partitions from [RFC2616]. 999 C.2. Since draft-ietf-httpbis-p4-conditional-00 1001 Closed issues: 1003 o : "Normative and 1004 Informative references" 1006 Other changes: 1008 o Move definitions of 304 and 412 condition codes from Part2. 1010 C.3. Since draft-ietf-httpbis-p4-conditional-01 1012 Ongoing work on ABNF conversion 1013 (): 1015 o Add explicit references to BNF syntax and rules imported from 1016 other parts of the specification. 1018 C.4. Since draft-ietf-httpbis-p4-conditional-02 1020 Closed issues: 1022 o : "Weak ETags on 1023 non-GET requests" 1025 Ongoing work on IANA Message Header Field Registration 1026 (): 1028 o Reference RFC 3984, and update header field registrations for 1029 header fields defined in this document. 1031 C.5. Since draft-ietf-httpbis-p4-conditional-03 1033 Closed issues: 1035 o : "Examples for 1036 ETag matching" 1038 o : "'entity 1039 value' undefined" 1041 o : "bogus 2068 1042 Date header reference" 1044 C.6. Since draft-ietf-httpbis-p4-conditional-04 1046 Ongoing work on ABNF conversion 1047 (): 1049 o Use "/" instead of "|" for alternatives. 1051 o Introduce new ABNF rules for "bad" whitespace ("BWS"), optional 1052 whitespace ("OWS") and required whitespace ("RWS"). 1054 o Rewrite ABNFs to spell out whitespace rules, factor out header 1055 field value format definitions. 1057 C.7. Since draft-ietf-httpbis-p4-conditional-05 1059 Final work on ABNF conversion 1060 (): 1062 o Add appendix containing collected and expanded ABNF, reorganize 1063 ABNF introduction. 1065 C.8. Since draft-ietf-httpbis-p4-conditional-06 1067 Closed issues: 1069 o : "case- 1070 sensitivity of etag weakness indicator" 1072 C.9. Since draft-ietf-httpbis-p4-conditional-07 1074 Closed issues: 1076 o : "Weak ETags on 1077 non-GET requests" (If-Match still was defined to require strong 1078 matching) 1080 o : "move IANA 1081 registrations for optional status codes" 1083 C.10. Since draft-ietf-httpbis-p4-conditional-08 1085 No significant changes. 1087 C.11. Since draft-ietf-httpbis-p4-conditional-09 1089 No significant changes. 1091 C.12. Since draft-ietf-httpbis-p4-conditional-10 1093 Closed issues: 1095 o : "Clarify 1096 'Requested Variant'" 1098 o : "Clarify 1099 entity / representation / variant terminology" 1101 o : "consider 1102 removing the 'changes from 2068' sections" 1104 C.13. Since draft-ietf-httpbis-p4-conditional-11 1106 None. 1108 C.14. Since draft-ietf-httpbis-p4-conditional-12 1110 Closed issues: 1112 o : "Header 1113 Classification" 1115 C.15. Since draft-ietf-httpbis-p4-conditional-13 1117 Closed issues: 1119 o : "If-* and 1120 entities" 1122 o : "Definition of 1123 validator weakness" 1125 o : "untangle 1126 ABNFs for header fields" 1128 o : "ETags and 1129 Quotes" 1131 C.16. Since draft-ietf-httpbis-p4-conditional-14 1133 None. 1135 C.17. Since draft-ietf-httpbis-p4-conditional-15 1137 Closed issues: 1139 o : "If-Range 1140 should be listed when dicussing contexts where L-M can be 1141 considered strong" 1143 Index 1145 3 1146 304 Not Modified (status code) 19 1148 4 1149 412 Precondition Failed (status code) 20 1151 E 1152 ETag header field 10 1154 G 1155 Grammar 1156 entity-tag 10 1157 ETag 10 1158 If-Match 15 1159 If-Modified-Since 17 1160 If-None-Match 16 1161 If-Unmodified-Since 18 1162 Last-Modified 8 1163 opaque-tag 10 1164 weak 10 1166 H 1167 Header Fields 1168 ETag 10 1169 If-Match 14 1170 If-Modified-Since 17 1171 If-None-Match 15 1172 If-Unmodified-Since 18 1173 Last-Modified 8 1175 I 1176 If-Match header field 14 1177 If-Modified-Since header field 17 1178 If-None-Match header field 15 1179 If-Unmodified-Since header field 18 1181 L 1182 Last-Modified header field 8 1184 M 1185 metadata 6 1187 S 1188 selected representation 5 1189 Status Codes 1190 304 Not Modified 19 1191 412 Precondition Failed 20 1193 V 1194 validator 6 1195 strong 6 1196 weak 6 1198 Authors' Addresses 1200 Roy T. Fielding (editor) 1201 Adobe Systems Incorporated 1202 345 Park Ave 1203 San Jose, CA 95110 1204 USA 1206 EMail: fielding@gbiv.com 1207 URI: http://roy.gbiv.com/ 1209 Jim Gettys 1210 Alcatel-Lucent Bell Labs 1211 21 Oak Knoll Road 1212 Carlisle, MA 01741 1213 USA 1215 EMail: jg@freedesktop.org 1216 URI: http://gettys.wordpress.com/ 1217 Jeffrey C. Mogul 1218 Hewlett-Packard Company 1219 HP Labs, Large Scale Systems Group 1220 1501 Page Mill Road, MS 1177 1221 Palo Alto, CA 94304 1222 USA 1224 EMail: JeffMogul@acm.org 1226 Henrik Frystyk Nielsen 1227 Microsoft Corporation 1228 1 Microsoft Way 1229 Redmond, WA 98052 1230 USA 1232 EMail: henrikn@microsoft.com 1234 Larry Masinter 1235 Adobe Systems Incorporated 1236 345 Park Ave 1237 San Jose, CA 95110 1238 USA 1240 EMail: LMM@acm.org 1241 URI: http://larry.masinter.net/ 1243 Paul J. Leach 1244 Microsoft Corporation 1245 1 Microsoft Way 1246 Redmond, WA 98052 1248 EMail: paulle@microsoft.com 1250 Tim Berners-Lee 1251 World Wide Web Consortium 1252 MIT Computer Science and Artificial Intelligence Laboratory 1253 The Stata Center, Building 32 1254 32 Vassar Street 1255 Cambridge, MA 02139 1256 USA 1258 EMail: timbl@w3.org 1259 URI: http://www.w3.org/People/Berners-Lee/ 1260 Yves Lafon (editor) 1261 World Wide Web Consortium 1262 W3C / ERCIM 1263 2004, rte des Lucioles 1264 Sophia-Antipolis, AM 06902 1265 France 1267 EMail: ylafon@w3.org 1268 URI: http://www.raubacapeu.net/people/yves/ 1270 Julian F. Reschke (editor) 1271 greenbytes GmbH 1272 Hafenweg 16 1273 Muenster, NW 48155 1274 Germany 1276 Phone: +49 251 2807760 1277 Fax: +49 251 2807761 1278 EMail: julian.reschke@greenbytes.de 1279 URI: http://greenbytes.de/tech/webdav/