source: draft-ietf-httpbis/latest/p4-conditional.xml @ 1802

Last change on this file since 1802 was 1802, checked in by julian.reschke@…, 7 years ago

Record changes for [1801]

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/xml
File size: 66.9 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<?xml-stylesheet type='text/xsl' href='../myxml2rfc.xslt'?>
3<!DOCTYPE rfc [
4  <!ENTITY MAY "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MAY</bcp14>">
5  <!ENTITY MUST "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST</bcp14>">
6  <!ENTITY MUST-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST NOT</bcp14>">
7  <!ENTITY OPTIONAL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>OPTIONAL</bcp14>">
8  <!ENTITY RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>RECOMMENDED</bcp14>">
9  <!ENTITY REQUIRED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>REQUIRED</bcp14>">
10  <!ENTITY SHALL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL</bcp14>">
11  <!ENTITY SHALL-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL NOT</bcp14>">
12  <!ENTITY SHOULD "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD</bcp14>">
13  <!ENTITY SHOULD-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD NOT</bcp14>">
14  <!ENTITY ID-VERSION "latest">
15  <!ENTITY ID-MONTH "July">
16  <!ENTITY ID-YEAR "2012">
17  <!ENTITY Note "<x:h xmlns:x='http://purl.org/net/xml2rfc/ext'>Note:</x:h>">
18  <!ENTITY architecture               "<xref target='Part1' x:rel='#architecture' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
19  <!ENTITY notation                   "<xref target='Part1' x:rel='#notation' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
20  <!ENTITY abnf-extension             "<xref target='Part1' x:rel='#abnf.extension' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
21  <!ENTITY acks                       "<xref target='Part1' x:rel='#acks' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
22  <!ENTITY whitespace                 "<xref target='Part1' x:rel='#whitespace' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
23  <!ENTITY field-components           "<xref target='Part1' x:rel='#field.components' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
24  <!ENTITY header-date                "<xref target='Part2' x:rel='#header.date' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
25  <!ENTITY messaging                  "<xref target='Part1' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
26  <!ENTITY caching                    "<xref target='Part6' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
27  <!ENTITY header-accept-encoding     "<xref target='Part2' x:rel='#header.accept-encoding' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
28  <!ENTITY header-if-range            "<xref target='Part5' x:rel='#header.if-range' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
29  <!ENTITY header-range               "<xref target='Part5' x:rel='#header.range' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
30  <!ENTITY header-vary                "<xref target='Part6' x:rel='#header.vary' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
31  <!ENTITY http-date                  "<xref target='Part2' x:rel='#http.date' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
32  <!ENTITY transfer-codings           "<xref target='Part1' x:rel='#transfer.codings' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
33  <!ENTITY content-negotiation        "<xref target='Part2' x:rel='#content.negotiation' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
34]>
35<?rfc toc="yes" ?>
36<?rfc symrefs="yes" ?>
37<?rfc sortrefs="yes" ?>
38<?rfc compact="yes"?>
39<?rfc subcompact="no" ?>
40<?rfc linkmailto="no" ?>
41<?rfc editing="no" ?>
42<?rfc comments="yes"?>
43<?rfc inline="yes"?>
44<?rfc rfcedstyle="yes"?>
45<?rfc-ext allow-markup-in-artwork="yes" ?>
46<?rfc-ext include-references-in-index="yes" ?>
47<rfc obsoletes="2616" category="std" x:maturity-level="proposed"
48     ipr="pre5378Trust200902" docName="draft-ietf-httpbis-p4-conditional-&ID-VERSION;"
49     xmlns:x='http://purl.org/net/xml2rfc/ext'>
50<x:link rel="prev" basename="p3-payload"/>
51<x:link rel="next" basename="p5-range"/>
52<x:feedback template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22&amp;body=&lt;{ref}&gt;:"/>
53<front>
54
55  <title abbrev="HTTP/1.1, Part 4">HTTP/1.1, part 4: Conditional Requests</title>
56
57  <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
58    <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
59    <address>
60      <postal>
61        <street>345 Park Ave</street>
62        <city>San Jose</city>
63        <region>CA</region>
64        <code>95110</code>
65        <country>USA</country>
66      </postal>
67      <email>fielding@gbiv.com</email>
68      <uri>http://roy.gbiv.com/</uri>
69    </address>
70  </author>
71
72  <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
73    <organization abbrev="W3C">World Wide Web Consortium</organization>
74    <address>
75      <postal>
76        <street>W3C / ERCIM</street>
77        <street>2004, rte des Lucioles</street>
78        <city>Sophia-Antipolis</city>
79        <region>AM</region>
80        <code>06902</code>
81        <country>France</country>
82      </postal>
83      <email>ylafon@w3.org</email>
84      <uri>http://www.raubacapeu.net/people/yves/</uri>
85    </address>
86  </author>
87
88  <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
89    <organization abbrev="greenbytes">greenbytes GmbH</organization>
90    <address>
91      <postal>
92        <street>Hafenweg 16</street>
93        <city>Muenster</city><region>NW</region><code>48155</code>
94        <country>Germany</country>
95      </postal>
96      <email>julian.reschke@greenbytes.de</email>
97      <uri>http://greenbytes.de/tech/webdav/</uri>
98    </address>
99  </author>
100
101  <date month="&ID-MONTH;" year="&ID-YEAR;"/>
102  <workgroup>HTTPbis Working Group</workgroup>
103
104<abstract>
105<t>
106   The Hypertext Transfer Protocol (HTTP) is an application-level protocol for
107   distributed, collaborative, hypertext information systems. This document
108   defines HTTP/1.1 conditional requests, including metadata header fields
109   for indicating state changes, request header fields for making
110   preconditions on such state, and rules for constructing the responses to a
111   conditional request when one or more preconditions evaluate to false.
112</t>
113</abstract>
114
115<note title="Editorial Note (To be removed by RFC Editor)">
116  <t>
117    Discussion of this draft takes place on the HTTPBIS working group
118    mailing list (ietf-http-wg@w3.org), which is archived at
119    <eref target="http://lists.w3.org/Archives/Public/ietf-http-wg/"/>.
120  </t>
121  <t>
122    The current issues list is at
123    <eref target="http://tools.ietf.org/wg/httpbis/trac/report/3"/> and related
124    documents (including fancy diffs) can be found at
125    <eref target="http://tools.ietf.org/wg/httpbis/"/>.
126  </t>
127  <t>
128    The changes in this draft are summarized in <xref target="changes.since.19"/>.
129  </t>
130</note>
131</front>
132
133<middle>
134<section title="Introduction" anchor="introduction">
135<t>
136   Conditional requests are HTTP requests <xref target="Part2"/> that include
137   one or more header fields indicating a precondition to be tested before
138   applying the method semantics to the target resource.
139   Each precondition is based on metadata that is expected to change if the
140   selected representation of the target resource is changed.
141   This document defines the HTTP/1.1 conditional request mechanisms in terms
142   of the architecture, syntax notation, and conformance criteria defined in
143   <xref target="Part1"/>.
144</t>
145<t>
146   Conditional GET requests are the most efficient mechanism for HTTP
147   cache updates &caching;.  Conditionals can also be
148   applied to state-changing methods, such as PUT and DELETE, to prevent
149   the "lost update" problem: one client accidentally overwriting
150   the work of another client that has been acting in parallel.
151</t>
152<t>
153   Conditional request preconditions are based on the state of the target
154   resource as a whole (its current value set) or the state as observed
155   in a previously obtained representation (one value in that set).
156   A resource might have multiple current representations, each with its
157   own observable state.  The conditional request mechanisms assume that
158   the mapping of requests to corresponding representations will be
159   consistent over time if the server intends to take advantage of
160   conditionals.  Regardless, if the mapping is inconsistent and
161   the server is unable to select the appropriate representation, then
162   no harm will result when the precondition evaluates to false.
163</t>
164<t><iref primary="true" item="selected representation"/>
165   We use the term "<x:dfn>selected representation</x:dfn>" to refer to
166   the current representation of the target resource that would have been
167   selected in a successful response if the same request had used the method
168   GET and had excluded all of the conditional request header fields.
169   The conditional request preconditions are evaluated by comparing the
170   values provided in the request header fields to the current metadata
171   for the selected representation.
172</t>
173
174<section title="Conformance and Error Handling" anchor="intro.conformance.and.error.handling">
175<t>
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 <xref target="RFC2119"/>.
179</t>
180<t>
181   This specification targets conformance criteria according to the role of
182   a participant in HTTP communication.  Hence, HTTP requirements are placed
183   on senders, recipients, clients, servers, user agents, intermediaries,
184   origin servers, proxies, gateways, or caches, depending on what behavior
185   is being constrained by the requirement. See &architecture; for definitions
186   of these terms.
187</t>
188<t>
189   The verb "generate" is used instead of "send" where a requirement
190   differentiates between creating a protocol element and merely forwarding a
191   received element downstream.
192</t>
193<t>
194   An implementation is considered conformant if it complies with all of the
195   requirements associated with the roles it partakes in HTTP. Note that
196   SHOULD-level requirements are relevant here, unless one of the documented
197   exceptions is applicable.
198</t>
199<t>
200   This document also uses ABNF to define valid protocol elements
201   (<xref target="notation"/>).
202   In addition to the prose requirements placed upon them, senders &MUST-NOT;
203   generate protocol elements that do not match the grammar defined by the
204   ABNF rules for those protocol elements that are applicable to the sender's
205   role. If a received protocol element is processed, the recipient &MUST; be
206   able to parse any value that would match the ABNF rules for that protocol
207   element, excluding only those rules not applicable to the recipient's role.
208</t>
209<t>
210   Unless noted otherwise, a recipient &MAY; attempt to recover a usable
211   protocol element from an invalid construct.  HTTP does not define
212   specific error handling mechanisms except when they have a direct impact
213   on security, since different applications of the protocol require
214   different error handling strategies.  For example, a Web browser might
215   wish to transparently recover from a response where the
216   <x:ref>Location</x:ref> header field doesn't parse according to the ABNF,
217   whereas a systems control client might consider any form of error recovery
218   to be dangerous.
219</t>
220</section>
221
222<section title="Syntax Notation" anchor="notation">
223  <x:anchor-alias value="ALPHA"/>
224  <x:anchor-alias value="CR"/>
225  <x:anchor-alias value="DIGIT"/>
226  <x:anchor-alias value="DQUOTE"/>
227  <x:anchor-alias value="LF"/>
228  <x:anchor-alias value="OCTET"/>
229  <x:anchor-alias value="VCHAR"/>
230  <x:anchor-alias value="core.rules"/>
231  <x:anchor-alias value="obs-text"/>
232  <x:anchor-alias value="OWS"/>
233  <x:anchor-alias value="HTTP-date"/>
234<t>
235   This specification uses the Augmented Backus-Naur Form (ABNF) notation
236   of <xref target="RFC5234"/> with the list rule extension defined in
237   &notation;<xref target="collected.abnf"/> shows the collected ABNF
238   with the list rule expanded.
239</t>
240<t>
241  The following core rules are included by
242  reference, as defined in <xref target="RFC5234" x:fmt="," x:sec="B.1"/>:
243  ALPHA (letters), CR (carriage return), CRLF (CR LF), CTL (controls),
244  DIGIT (decimal 0-9), DQUOTE (double quote),
245  HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed),
246  OCTET (any 8-bit sequence of data), SP (space), and
247  VCHAR (any visible US-ASCII character).
248</t>
249<t>
250  The ABNF rules below are defined in <xref target="Part1"/> and
251  <xref target="Part2"/>:
252</t>
253<figure><artwork type="abnf2616">
254  <x:ref>OWS</x:ref>           = &lt;OWS, defined in &whitespace;&gt;
255  <x:ref>obs-text</x:ref>      = &lt;obs-text, defined in &field-components;&gt;
256  <x:ref>HTTP-date</x:ref>     = &lt;HTTP-date, defined in &http-date;&gt;
257</artwork></figure>
258</section>
259</section>
260
261<section title="Validators" anchor="validators">
262   <iref primary="true" item="metadata"/>
263   <iref primary="true" item="validator"/>
264<t>
265   This specification defines two forms of metadata that are commonly used
266   to observe resource state and test for preconditions: modification dates
267   (<xref target="header.last-modified"/>) and opaque entity tags
268   (<xref target="header.etag"/>).  Additional metadata that reflects resource state
269   has been defined by various extensions of HTTP, such as WebDAV
270   <xref target="RFC4918"/>, that are beyond the scope of this specification.
271   A resource metadata value is referred to as a "<x:dfn>validator</x:dfn>"
272   when it is used within a precondition.
273</t>
274
275<section title="Weak versus Strong" anchor="weak.and.strong.validators">
276   <iref primary="true" item="validator" subitem="weak"/>
277   <iref primary="true" item="validator" subitem="strong"/>
278<t>
279   Validators come in two flavors: strong or weak.  Weak validators are easy
280   to generate but are far less useful for comparisons.  Strong validators
281   are ideal for comparisons but can be very difficult (and occasionally
282   impossible) to generate efficiently.  Rather than impose that all forms
283   of resource adhere to the same strength of validator, HTTP exposes the
284   type of validator in use and imposes restrictions on when weak validators
285   can be used as preconditions.
286</t>
287<t>
288   A "strong validator" is a representation metadata value that &MUST; be
289   changed to a new, previously unused or guaranteed unique, value whenever
290   a change occurs to the representation data such that a change would be
291   observable in the payload body of a <x:ref>200 (OK)</x:ref> response to GET.
292</t>
293<t>   
294   A strong validator &MAY; be changed for other reasons, such as when a semantically
295   significant part of the representation metadata is changed (e.g.,
296   <x:ref>Content-Type</x:ref>), but it is in the best interests of the origin
297   server to only change the value when it is necessary to invalidate the
298   stored responses held by remote caches and authoring tools.  A strong
299   validator &MUST; be unique across all representations of a given resource,
300   such that no two representations of that resource share the same validator
301   unless their payload body would be identical.
302</t>
303<t>
304   Cache entries might persist for arbitrarily long periods, regardless
305   of expiration times.  Thus, a cache might attempt to validate an
306   entry using a validator that it obtained in the distant past.
307   A strong validator &MUST; be unique across all versions of all
308   representations associated with a particular resource over time.
309   However, there is no implication of uniqueness across representations
310   of different resources (i.e., the same strong validator might be
311   in use for representations of multiple resources at the same time
312   and does not imply that those representations are equivalent).
313</t>
314<t>
315   There are a variety of strong validators used in practice.  The best are
316   based on strict revision control, wherein each change to a representation
317   always results in a unique node name and revision identifier being assigned
318   before the representation is made accessible to GET.  A collision-resistant hash
319   function applied to the representation data is also sufficient if the data
320   is available prior to the response header fields being sent and the digest
321   does not need to be recalculated every time a validation request is
322   received.  However, if a resource has distinct representations that differ
323   only in their metadata, such as might occur with content negotiation over
324   media types that happen to share the same data format, then the origin
325   server &SHOULD; incorporate additional information in the validator to
326   distinguish those representations and avoid confusing cache behavior.
327</t>
328<t>
329   In contrast, a "weak validator" is a representation metadata value that
330   might not be changed for every change to the representation data.  This
331   weakness might be due to limitations in how the value is calculated, such
332   as clock resolution or an inability to ensure uniqueness for all possible
333   representations of the resource, or due to a desire by the resource owner
334   to group representations by some self-determined set of equivalency
335   rather than unique sequences of data.  An origin server &SHOULD; change a
336   weak entity-tag whenever it considers prior representations to be
337   unacceptable as a substitute for the current representation. In other words,
338   a weak entity-tag ought to change whenever the origin server wants caches to
339   invalidate old responses.
340</t>
341<t>
342   For example, the representation of a weather report that changes in
343   content every second, based on dynamic measurements, might be grouped
344   into sets of equivalent representations (from the origin server's
345   perspective) with the same weak validator in order to allow cached
346   representations to be valid for a reasonable period of time (perhaps
347   adjusted dynamically based on server load or weather quality).
348   Likewise, a representation's modification time, if defined with only
349   one-second resolution, might be a weak validator if it is possible
350   for the representation to be modified twice during a single second and
351   retrieved between those modifications.
352</t>
353<t>
354   A "use" of a validator occurs when either a client generates a request
355   and includes the validator in a precondition or when a server
356   compares two validators.
357   Weak validators are only usable in contexts that do not depend on exact
358   equality of a representation's payload body.
359   Strong validators are usable and preferred for all conditional requests,
360   including cache validation, partial content ranges, and "lost update"
361   avoidance.
362</t>
363</section>
364
365<section title="Last-Modified" anchor="header.last-modified">
366  <iref primary="true" item="Last-Modified header field" x:for-anchor=""/>
367  <iref primary="true" item="Header Fields" subitem="Last-Modified" x:for-anchor=""/>
368  <x:anchor-alias value="Last-Modified"/>
369<t>
370   The "Last-Modified" header field indicates the date and time at
371   which the origin server believes the selected representation was
372   last modified.
373</t>
374<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="Last-Modified"/>
375  <x:ref>Last-Modified</x:ref> = <x:ref>HTTP-date</x:ref>
376</artwork></figure>
377<t>
378   An example of its use is
379</t>
380<figure><artwork type="example">
381  Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
382</artwork></figure>
383
384<section title="Generation" anchor="lastmod.generation">
385<t>
386   Origin servers &SHOULD; send Last-Modified for any selected
387   representation for which a last modification date can be reasonably
388   and consistently determined, since its use in conditional requests
389   and evaluating cache freshness (&caching;) results in a substantial
390   reduction of HTTP traffic on the Internet and can be a significant
391   factor in improving service scalability and reliability.
392</t>
393<t>
394   A representation is typically the sum of many parts behind the
395   resource interface.  The last-modified time would usually be
396   the most recent time that any of those parts were changed.
397   How that value is determined for any given resource is an
398   implementation detail beyond the scope of this specification.
399   What matters to HTTP is how recipients of the Last-Modified
400   header field can use its value to make conditional requests
401   and test the validity of locally cached responses.
402</t>
403<t>
404   An origin server &SHOULD; obtain the Last-Modified value of the
405   representation as close as possible to the time that it generates the
406   <x:ref>Date</x:ref> field value for its response. This allows a recipient to
407   make an accurate assessment of the representation's modification time,
408   especially if the representation changes near the time that the
409   response is generated.
410</t>
411<t>
412   An origin server with a clock &MUST-NOT; send a Last-Modified date
413   that is later than the server's time of message origination (<x:ref>Date</x:ref>).
414   If the last modification time is derived from implementation-specific
415   metadata that evaluates to some time in the future, according to the
416   origin server's clock, then the origin server &MUST; replace that
417   value with the message origination date. This prevents a future
418   modification date from having an adverse impact on cache validation.
419</t>
420<t>
421   An origin server without a clock &MUST-NOT; assign Last-Modified
422   values to a response unless these values were associated
423   with the resource by some other system or user with a reliable clock.
424</t>
425</section>
426
427<section title="Comparison" anchor="lastmod.comparison">
428<t>
429   A Last-Modified time, when used as a validator in a request, is
430   implicitly weak unless it is possible to deduce that it is strong,
431   using the following rules:
432  <list style="symbols">
433     <t>The validator is being compared by an origin server to the
434        actual current validator for the representation and,</t>
435     <t>That origin server reliably knows that the associated representation did
436        not change twice during the second covered by the presented
437        validator.</t>
438  </list>
439</t>
440<t>
441   or
442  <list style="symbols">
443     <t>The validator is about to be used by a client in an <x:ref>If-Modified-Since</x:ref>,
444        <x:ref>If-Unmodified-Since</x:ref> header field, because the client has
445        a cache entry, or <x:ref>If-Range</x:ref> for the associated
446        representation, and</t>
447     <t>That cache entry includes a <x:ref>Date</x:ref> value, which gives the
448        time when the origin server sent the original response, and</t>
449     <t>The presented Last-Modified time is at least 60 seconds before
450        the Date value.</t>
451  </list>
452</t>
453<t>
454   or
455  <list style="symbols">
456     <t>The validator is being compared by an intermediate cache to the
457        validator stored in its cache entry for the representation, and</t>
458     <t>That cache entry includes a <x:ref>Date</x:ref> value, which gives the
459        time when the origin server sent the original response, and</t>
460     <t>The presented Last-Modified time is at least 60 seconds before
461        the Date value.</t>
462  </list>
463</t>
464<t>
465   This method relies on the fact that if two different responses were
466   sent by the origin server during the same second, but both had the
467   same Last-Modified time, then at least one of those responses would
468   have a <x:ref>Date</x:ref> value equal to its Last-Modified time. The
469   arbitrary 60-second limit guards against the possibility that the Date and
470   Last-Modified values are generated from different clocks, or at somewhat
471   different times during the preparation of the response. An
472   implementation &MAY; use a value larger than 60 seconds, if it is
473   believed that 60 seconds is too short.
474</t>
475</section>
476</section>
477
478<section title="ETag" anchor="header.etag">
479  <iref primary="true" item="ETag header field" x:for-anchor=""/>
480  <iref primary="true" item="Header Fields" subitem="ETag" x:for-anchor=""/>
481  <x:anchor-alias value="ETag"/>
482  <x:anchor-alias value="entity-tag"/>
483  <x:anchor-alias value="entity.tags"/>
484  <x:anchor-alias value="opaque-tag"/>
485  <x:anchor-alias value="weak"/>
486  <x:anchor-alias value="etagc"/>
487<t>
488   The "ETag" header field provides the current entity-tag for the
489   selected representation.
490   An entity-tag is an opaque validator for differentiating between
491   multiple representations of the same resource, regardless of whether
492   those multiple representations are due to resource state changes over
493   time, content negotiation resulting in multiple representations being
494   valid at the same time, or both. An entity-tag consists of an opaque
495   quoted string, possibly prefixed by a weakness indicator.
496</t>
497<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="ETag"/><iref primary="true" item="Grammar" subitem="entity-tag"/><iref primary="true" item="Grammar" subitem="weak"/><iref primary="true" item="Grammar" subitem="opaque-tag"/><iref primary="true" item="Grammar" subitem="etagc"/>
498  <x:ref>ETag</x:ref>       = <x:ref>entity-tag</x:ref>
499
500  <x:ref>entity-tag</x:ref> = [ <x:ref>weak</x:ref> ] <x:ref>opaque-tag</x:ref>
501  <x:ref>weak</x:ref>       = <x:abnf-char-sequence>"W/"</x:abnf-char-sequence> ; "W/", case-sensitive
502  <x:ref>opaque-tag</x:ref> = <x:ref>DQUOTE</x:ref> *<x:ref>etagc</x:ref> <x:ref>DQUOTE</x:ref>
503  <x:ref>etagc</x:ref>      = %x21 / %x23-7E / <x:ref>obs-text</x:ref>
504             ; <x:ref>VCHAR</x:ref> except double quotes, plus obs-text
505</artwork></figure>
506<x:note>
507  <t>
508    &Note; Previously, opaque-tag was defined to be a quoted-string
509    (<xref target="RFC2616" x:fmt="," x:sec="3.11"/>), thus some recipients
510    might perform backslash unescaping. Servers therefore ought to avoid
511    backslash characters in entity tags.
512  </t>
513</x:note>
514<t>
515   An entity-tag can be more reliable for validation than a modification
516   date in situations where it is inconvenient to store modification
517   dates, where the one-second resolution of HTTP date values is not
518   sufficient, or where modification dates are not consistently maintained.
519</t>
520<figure><preamble>
521  Examples:
522</preamble>
523<artwork type="example">
524  ETag: "xyzzy"
525  ETag: W/"xyzzy"
526  ETag: ""
527</artwork></figure>
528<t>
529   An entity-tag can be either a weak or strong validator, with
530   strong being the default.  If an origin server provides an entity-tag
531   for a representation and the generation of that entity-tag does not satisfy
532   the requirements for a strong validator
533   (<xref target="weak.and.strong.validators"/>), then that
534   entity-tag &MUST; be marked as weak by prefixing its opaque value
535   with "W/" (case-sensitive).
536</t>
537
538<section title="Generation" anchor="entity.tag.generation">
539<t>
540   The principle behind entity-tags is that only the service author
541   knows the implementation of a resource well enough to select the
542   most accurate and efficient validation mechanism for that resource,
543   and that any such mechanism can be mapped to a simple sequence of
544   octets for easy comparison.  Since the value is opaque, there is no
545   need for the client to be aware of how each entity-tag is constructed.
546</t>
547<t>
548   For example, a resource that has implementation-specific versioning
549   applied to all changes might use an internal revision number, perhaps
550   combined with a variance identifier for content negotiation, to
551   accurately differentiate between representations.
552   Other implementations might use a collision-resistant hash of
553   representation content,
554   a combination of various filesystem attributes, or a modification
555   timestamp that has sub-second resolution.
556</t>
557<t>
558   Origin servers &SHOULD; send ETag for any selected representation
559   for which detection of changes can be reasonably and consistently
560   determined, since the entity-tag's use in conditional requests and
561   evaluating cache freshness (&caching;) can result in a substantial
562   reduction of HTTP network traffic and can be a significant factor in
563   improving service scalability and reliability.
564</t>
565</section>
566
567<section title="Comparison" anchor="entity.tag.comparison">
568  <x:anchor-alias value="validator.comparison"/>
569<t>
570   There are two entity-tag comparison functions, depending
571   on whether the comparison context allows the use of weak validators
572   or not:
573  <list style="symbols">
574     <t>The strong comparison function: in order to be considered equal,
575        both opaque-tags &MUST; be identical character-by-character, and both
576        &MUST-NOT; be weak.</t>
577     <t>The weak comparison function: in order to be considered equal, both
578        opaque-tags &MUST; be identical character-by-character, but
579        either or both of them &MAY; be tagged as "weak" without affecting
580        the result.</t>
581  </list>
582</t>
583<t>
584   The example below shows the results for a set of entity-tag pairs,
585   and both the weak and strong comparison function results:
586</t>
587<texttable align="left">
588  <ttcol>ETag 1</ttcol>
589  <ttcol>ETag 2</ttcol>
590  <ttcol>Strong Comparison</ttcol>
591  <ttcol>Weak Comparison</ttcol>
592
593  <c>W/"1"</c>
594  <c>W/"1"</c>
595  <c>no match</c>
596  <c>match</c>
597 
598  <c>W/"1"</c>
599  <c>W/"2"</c>
600  <c>no match</c>
601  <c>no match</c>
602
603  <c>W/"1"</c>
604  <c>"1"</c>
605  <c>no match</c>
606  <c>match</c>
607
608  <c>"1"</c>
609  <c>"1"</c>
610  <c>match</c>
611  <c>match</c>
612</texttable>
613</section>
614
615<section title="Example: Entity-tags varying on Content-Negotiated Resources" anchor="example.entity.tag.vs.conneg">
616<t>
617   Consider a resource that is subject to content negotiation (&content-negotiation;),
618   and where the representations returned upon a GET request vary based on
619   the <x:ref>Accept-Encoding</x:ref> request header field
620   (&header-accept-encoding;):
621</t>
622<figure><preamble>>> Request:</preamble><artwork type="message/http; msgtype=&#34;request&#34;"  x:indent-with="  ">
623GET /index HTTP/1.1
624Host: www.example.com
625Accept-Encoding: gzip
626
627</artwork></figure>
628<t>
629   In this case, the response might or might not use the gzip content coding.
630   If it does not, the response might look like:
631</t>
632<figure><preamble>>> Response:</preamble><artwork type="message/http; msgtype=&#34;response&#34;"  x:indent-with="  ">
633HTTP/1.1 200 OK
634Date: Thu, 26 Mar 2010 00:05:00 GMT
635ETag: "123-a"
636Content-Length: <x:length-of target="exbody"/>
637Vary: Accept-Encoding
638Content-Type: text/plain
639
640<x:span anchor="exbody">Hello World!
641Hello World!
642Hello World!
643Hello World!
644Hello World!
645</x:span></artwork></figure>
646<t>
647   An alternative representation that does use gzip content coding would be:
648</t>
649<figure><preamble>>> Response:</preamble><artwork type="message/http; msgtype=&#34;response&#34;"  x:indent-with="  ">
650HTTP/1.1 200 OK
651Date: Thu, 26 Mar 2010 00:05:00 GMT
652ETag: "123-b"
653Content-Length: 43
654Vary: Accept-Encoding
655Content-Type: text/plain
656Content-Encoding: gzip
657
658<spanx>...binary data...</spanx></artwork></figure>
659<x:note>
660  <t>
661    &Note; Content codings are a property of the representation,
662    so therefore an entity-tag of an encoded representation has to be distinct
663    from an unencoded representation to prevent conflicts during cache updates
664    and range requests.  In contrast, transfer codings (&transfer-codings;)
665    apply only during message transfer and do not require distinct entity-tags.
666  </t>
667</x:note>
668</section>
669</section>
670
671<section title="Rules for When to Use Entity-tags and Last-Modified Dates" anchor="rules.for.when.to.use.entity.tags.and.last-modified.dates">
672<t>
673   We adopt a set of rules and recommendations for origin servers,
674   clients, and caches regarding when various validator types ought to
675   be used, and for what purposes.
676</t>
677<t>
678   HTTP/1.1 origin servers:
679  <list style="symbols">
680     <t>&SHOULD; send an entity-tag validator unless it is not feasible to
681        generate one.</t>
682
683     <t>&MAY; send a weak entity-tag instead of a strong entity-tag, if
684        performance considerations support the use of weak entity-tags,
685        or if it is unfeasible to send a strong entity-tag.</t>
686
687     <t>&SHOULD; send a <x:ref>Last-Modified</x:ref> value if it is feasible to
688        send one.</t>
689  </list>
690</t>
691<t>
692   In other words, the preferred behavior for an HTTP/1.1 origin server
693   is to send both a strong entity-tag and a <x:ref>Last-Modified</x:ref> value.
694</t>
695<t>
696   HTTP/1.1 clients:
697  <list style="symbols">
698     <t>&MUST; use that entity-tag in any cache-conditional request (using
699        <x:ref>If-Match</x:ref> or <x:ref>If-None-Match</x:ref>) if an
700        entity-tag has been provided by the origin server.</t>
701
702     <t>&SHOULD; use the <x:ref>Last-Modified</x:ref> value in non-subrange
703        cache-conditional requests (using <x:ref>If-Modified-Since</x:ref>)
704        if only a Last-Modified value has been provided by the origin server.</t>
705
706     <t>&MAY; use the <x:ref>Last-Modified</x:ref> value in subrange
707        cache-conditional requests (using <x:ref>If-Unmodified-Since</x:ref>)
708        if only a Last-Modified value has been provided by an HTTP/1.0 origin
709        server. The user agent &SHOULD; provide a way to disable this, in case
710        of difficulty.</t>
711
712     <t>&SHOULD; use both validators in cache-conditional requests if both an
713        entity-tag and a <x:ref>Last-Modified</x:ref> value have been provided
714        by the origin server. This allows both HTTP/1.0 and HTTP/1.1 caches to
715        respond appropriately.</t>
716  </list>
717</t>
718<t>
719   An HTTP/1.1 origin server, upon receiving a conditional request that
720   includes both a Last-Modified date (e.g., in an <x:ref>If-Modified-Since</x:ref>
721   or <x:ref>If-Unmodified-Since</x:ref> header field) and one or more
722   entity-tags (e.g., in an <x:ref>If-Match</x:ref>, <x:ref>If-None-Match</x:ref>,
723   or <x:ref>If-Range</x:ref> header field) as cache validators, &MUST-NOT;
724   return a response status code of <x:ref>304 (Not Modified)</x:ref> unless
725   doing so is consistent with all of the conditional header fields in the
726   request.
727</t>
728<t>
729   An HTTP/1.1 caching proxy, upon receiving a conditional request that
730   includes both a Last-Modified date and one or more entity-tags as
731   cache validators, &MUST-NOT; return a locally cached response to the
732   client unless that cached response is consistent with all of the
733   conditional header fields in the request.
734  <list><t>
735      &Note; The general principle behind these rules is that HTTP/1.1
736      servers and clients ought to transmit as much non-redundant
737      information as is available in their responses and requests.
738      HTTP/1.1 systems receiving this information will make the most
739      conservative assumptions about the validators they receive.
740  </t><t>
741      HTTP/1.0 clients and caches might ignore entity-tags. Generally,
742      last-modified values received or used by these systems will
743      support transparent and efficient caching, and so HTTP/1.1 origin
744      servers still ought to provide Last-Modified values.
745  </t></list>
746</t>
747</section>
748</section>
749
750<section title="Precondition Header Fields" anchor="header.field.definitions">
751<t>
752   This section defines the syntax and semantics of HTTP/1.1 header fields
753   for applying preconditions on requests.
754   <xref target="precedence"/> defines the order of evaluation when
755   more than one precondition is present in a request.
756</t>
757
758<section title="If-Match" anchor="header.if-match">
759  <iref primary="true" item="If-Match header field" x:for-anchor=""/>
760  <iref primary="true" item="Header Fields" subitem="If-Match" x:for-anchor=""/>
761  <x:anchor-alias value="If-Match"/>
762<t>
763   The "If-Match" header field can be used to make a request method conditional
764   on the current existence or value of an entity-tag for one or more
765   representations of the target resource.
766</t>
767<t>
768   If-Match is generally useful for resource update requests, such as PUT
769   requests, as a means for protecting against accidental overwrites when
770   multiple clients are acting in parallel on the same resource (i.e., the
771   "lost update" problem).  An If-Match field-value of "*" places the
772   precondition on the existence of any current representation for the
773   target resource.
774</t>
775<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="If-Match"/>
776  <x:ref>If-Match</x:ref> = "*" / 1#<x:ref>entity-tag</x:ref>
777</artwork></figure>
778<t>
779   The If-Match condition is met if and only if any of the entity-tags listed
780   in the If-Match field value match the entity-tag of the selected
781   representation for the target resource (as per <xref
782   target="entity.tag.comparison"/>), or if "*" is given and any current
783   representation exists for the target resource.
784</t>
785<t>
786   If the condition is met, the server &MAY; perform the request method as if
787   the If-Match header field was not present.
788</t>
789<t>
790   Origin servers &MUST-NOT; perform the requested method if the condition is
791   not met; instead they &MUST; respond with the <x:ref>412 (Precondition
792   Failed)</x:ref> status code.
793</t>
794<t>
795   Proxy servers using a cached response as the selected representation
796   &MUST-NOT; perform the requested method if the condition is not met;
797   instead, they &MUST; forward the request towards the origin server.
798</t>
799<t>
800   If the request would, without the If-Match header field, result in
801   anything other than a <x:ref>2xx (Successful)</x:ref> or <x:ref>412 (Precondition Failed)</x:ref>
802   status code, then the If-Match header field &MUST; be ignored.
803</t>
804<t>
805   Examples:
806</t>
807<figure><artwork type="example">
808  If-Match: "xyzzy"
809  If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
810  If-Match: *
811</artwork></figure>
812</section>
813
814<section title="If-None-Match" anchor="header.if-none-match">
815  <iref primary="true" item="If-None-Match header field" x:for-anchor=""/>
816  <iref primary="true" item="Header Fields" subitem="If-None-Match" x:for-anchor=""/>
817  <x:anchor-alias value="If-None-Match"/>
818<t>
819   The "If-None-Match" header field can be used to make a request method
820   conditional on not matching any of the current entity-tag values for
821   representations of the target resource.
822</t>
823<t>
824   If-None-Match is primarily used in conditional GET requests to enable
825   efficient updates of cached information with a minimum amount of transaction
826   overhead. A client that has one or more representations previously obtained
827   from the target resource can send If-None-Match with a list of the
828   associated entity-tags in the hope of receiving a <x:ref>304 (Not
829   Modified)</x:ref> response if at least one of those representations matches
830   the selected representation.
831</t>
832<t>
833   If-None-Match can also be used with a value of "*" to prevent an unsafe
834   request method (e.g., PUT) from inadvertently modifying an existing
835   representation of the target resource when the client believes that
836   the resource does not have a current representation.  This is a variation
837   on the "lost update" problem that might arise if more than one client
838   attempts to create an initial representation for the target resource.
839</t>
840<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="If-None-Match"/>
841  <x:ref>If-None-Match</x:ref> = "*" / 1#<x:ref>entity-tag</x:ref>
842</artwork></figure>
843<t>
844   The If-None-Match condition is met if and only if none of the entity-tags
845   listed in the If-None-Match field value match the entity-tag of the selected
846   representation for the target resource (as per <xref
847   target="entity.tag.comparison"/>), or if "*" is given and no current
848   representation exists for that resource.
849</t>
850<t>
851   If the condition is not met, the server &MUST-NOT; perform the requested
852   method. Instead, if the request method was GET or HEAD, the server &SHOULD;
853   respond with a <x:ref>304 (Not Modified)</x:ref> status code, including the
854   cache-related header fields (particularly <x:ref>ETag</x:ref>) of the
855   selected representation that has a matching entity-tag. For all other
856   request methods, the server &MUST; respond with a <x:ref>412 (Precondition
857   Failed)</x:ref> status code.
858</t>
859<t>
860   If the condition is met, the server &MAY; perform the requested method
861   as if the If-None-Match header field did not exist, but &MUST; also ignore
862   any <x:ref>If-Modified-Since</x:ref> header field(s) in the request. That
863   is, if no entity-tags match, then the server &MUST-NOT; return a <x:ref>304
864   (Not Modified)</x:ref> response.
865</t>
866<t>
867   If the request would, without the If-None-Match header field, result
868   in anything other than a <x:ref>2xx (Successful)</x:ref> or
869   <x:ref>304 (Not Modified)</x:ref> status code, then the If-None-Match
870   header field &MUST; be ignored. (See <xref
871   target="rules.for.when.to.use.entity.tags.and.last-modified.dates"/> for
872   a discussion of server behavior when both <x:ref>If-Modified-Since</x:ref>
873   and If-None-Match appear in the same request.)
874</t>
875<t>
876   Examples:
877</t>
878<figure><artwork type="example">
879  If-None-Match: "xyzzy"
880  If-None-Match: W/"xyzzy"
881  If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
882  If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"
883  If-None-Match: *
884</artwork></figure>
885</section>
886
887<section title="If-Modified-Since" anchor="header.if-modified-since">
888  <iref primary="true" item="If-Modified-Since header field" x:for-anchor=""/>
889  <iref primary="true" item="Header Fields" subitem="If-Modified-Since" x:for-anchor=""/>
890  <x:anchor-alias value="If-Modified-Since"/>
891<t>
892   The "If-Modified-Since" header field can be used with GET or HEAD to make
893   the method conditional by modification date: if the selected representation
894   has not been modified since the time specified in this field, then
895   do not perform the request method; instead, respond as detailed below.
896</t>
897<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="If-Modified-Since"/>
898  <x:ref>If-Modified-Since</x:ref> = <x:ref>HTTP-date</x:ref>
899</artwork></figure>
900<t>
901   An example of the field is:
902</t>
903<figure><artwork type="example">
904  If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
905</artwork></figure>
906<t>
907   A GET method with an If-Modified-Since header field and no <x:ref>Range</x:ref>
908   header field requests that the selected representation be transferred only if
909   it has been modified since the date given by the If-Modified-Since
910   header field.
911   The algorithm for determining this includes the following cases:
912  <list style="numbers">
913      <t>If the request would normally result in anything other than a
914         <x:ref>200 (OK)</x:ref> status code, or if the passed If-Modified-Since date is
915         invalid, the response is exactly the same as for a normal GET.
916         A date which is later than the server's current time is
917         invalid.</t>
918
919      <t>If the selected representation has been modified since the
920         If-Modified-Since date, the response is exactly the same as for
921         a normal GET.</t>
922
923      <t>If the selected representation has not been modified since a valid
924         If-Modified-Since date, the server &SHOULD; return a
925         <x:ref>304 (Not Modified)</x:ref> response.</t>
926  </list>
927</t>
928<t>
929   The purpose of this feature is to allow efficient updates of cached
930   information with a minimum amount of transaction overhead.
931  <list><t>
932      &Note; The <x:ref>Range</x:ref> header field modifies the meaning of
933      If-Modified-Since; see &header-range; for full details.
934    </t><t>
935      &Note; If-Modified-Since times are interpreted by the server, whose
936      clock might not be synchronized with the client.
937    </t><t>
938      &Note; When handling an If-Modified-Since header field, some
939      servers will use an exact date comparison function, rather than a
940      less-than function, for deciding whether to send a <x:ref>304 (Not Modified)</x:ref>
941      response. To get best results when sending an If-Modified-Since
942      header field for cache validation, clients are
943      advised to use the exact date string received in a previous
944      <x:ref>Last-Modified</x:ref> header field whenever possible.
945    </t><t>
946      &Note; If a client uses an arbitrary date in the If-Modified-Since
947      header field instead of a date taken from the <x:ref>Last-Modified</x:ref>
948      header field for the same request, the client needs to be aware that this
949      date is interpreted in the server's understanding of time.
950      Unsynchronized clocks and rounding problems, due to the different
951      encodings of time between the client and server, are concerns.
952      This includes the possibility of race conditions if the
953      document has changed between the time it was first requested and
954      the If-Modified-Since date of a subsequent request, and the
955      possibility of clock-skew-related problems if the If-Modified-Since
956      date is derived from the client's clock without correction
957      to the server's clock. Corrections for different time bases
958      between client and server are at best approximate due to network
959      latency.
960    </t>
961  </list>
962</t>
963</section>
964
965<section title="If-Unmodified-Since" anchor="header.if-unmodified-since">
966  <iref primary="true" item="If-Unmodified-Since header field" x:for-anchor=""/>
967  <iref primary="true" item="Header Fields" subitem="If-Unmodified-Since" x:for-anchor=""/>
968  <x:anchor-alias value="If-Unmodified-Since"/>
969<t>
970   The "If-Unmodified-Since" header field can be used to make a request
971   method conditional by modification date: if the selected representation
972   has been modified since the time specified in this field, then the
973   server &MUST-NOT; perform the requested operation and &MUST; instead
974   respond with the <x:ref>412 (Precondition Failed)</x:ref> status code.
975   If the selected representation has not been modified since the time
976   specified in this field, the server &SHOULD; perform the request
977   method as if the If-Unmodified-Since header field were not present.
978</t>
979<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="If-Unmodified-Since"/>
980  <x:ref>If-Unmodified-Since</x:ref> = <x:ref>HTTP-date</x:ref>
981</artwork></figure>
982<t>
983   An example of the field is:
984</t>
985<figure><artwork type="example">
986  If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
987</artwork></figure>
988<t>
989   If a request normally (i.e., in absence of the If-Unmodified-Since
990   header field) would result in anything other than a <x:ref>2xx (Successful)</x:ref>
991   or <x:ref>412 (Precondition Failed)</x:ref> status code,
992   the If-Unmodified-Since header field &SHOULD; be ignored.
993</t>
994<t>
995   If the specified date is invalid, the header field &MUST; be ignored.
996</t>
997</section>
998
999<section title="If-Range" anchor="header.if-range">
1000<t>
1001   The "If-Range" header field provides a special conditional request
1002   mechanism that is similar to <x:ref>If-Match</x:ref> and
1003   <x:ref>If-Unmodified-Since</x:ref> but specific to HTTP range requests.
1004   If-Range is defined in &header-if-range;.
1005</t>
1006</section>
1007
1008</section>
1009
1010<section title="Status Code Definitions" anchor="status.code.definitions">
1011<section title="304 Not Modified" anchor="status.304">
1012  <iref primary="true" item="304 Not Modified (status code)" x:for-anchor=""/>
1013  <iref primary="true" item="Status Codes" subitem="304 Not Modified" x:for-anchor=""/>
1014  <x:anchor-alias value="304"/>
1015  <x:anchor-alias value="304 (Not Modified)"/>
1016<t>
1017   The 304 status code indicates that a conditional GET request has been
1018   received and would have resulted in a <x:ref>200 (OK)</x:ref> response if it were not
1019   for the fact that the condition has evaluated to false.  In other words,
1020   there is no need for the server to transfer a representation of the
1021   target resource because the client's request indicates that it already
1022   has a valid representation, as indicated by the 304 response header
1023   fields, and is therefore redirecting the client to make use of that
1024   stored representation as if it were the payload of a 200 response.
1025   The 304 response &MUST-NOT; contain a message-body, and thus is always
1026   terminated by the first empty line after the header fields.
1027</t>
1028<t>
1029   A 304 response &MUST; include a <x:ref>Date</x:ref> header field
1030   (&header-date;) unless the origin server does not have a clock that can
1031   provide a reasonable approximation of the current time.  If a <x:ref>200
1032   (OK)</x:ref> response to the same request would have included any of the
1033   header fields <x:ref>Cache-Control</x:ref>, <x:ref>Content-Location</x:ref>,
1034   <x:ref>ETag</x:ref>, <x:ref>Expires</x:ref>, or <x:ref>Vary</x:ref>, then
1035   those same header fields &MUST; be sent in a 304 response.
1036</t>
1037<t>
1038   Since the goal of a 304 response is to minimize information transfer
1039   when the recipient already has one or more cached representations,
1040   the response &SHOULD-NOT; include representation metadata other
1041   than the above listed fields unless said metadata exists for the
1042   purpose of guiding cache updates (e.g., future HTTP extensions).
1043</t>
1044<t>
1045   If the recipient of a 304 response does not have a cached representation
1046   corresponding to the entity-tag indicated by the 304 response, then the
1047   recipient &MUST-NOT; use the 304 to update its own cache.  If this
1048   conditional request originated with an outbound client, such as a user agent
1049   with its own cache sending a conditional GET to a shared proxy, then the 304
1050   response &MAY; be forwarded to that client.  Otherwise, the recipient &MUST;
1051   disregard the 304 response and repeat the request without any preconditions.
1052</t>
1053<t>
1054   If a cache uses a received 304 response to update a cache entry, the
1055   cache &MUST; update the entry to reflect any new field values given in
1056   the response.
1057</t>
1058</section>
1059
1060<section title="412 Precondition Failed" anchor="status.412">
1061  <iref primary="true" item="412 Precondition Failed (status code)" x:for-anchor=""/>
1062  <iref primary="true" item="Status Codes" subitem="412 Precondition Failed" x:for-anchor=""/>
1063  <x:anchor-alias value="412 (Precondition Failed)"/>
1064<t>
1065   The 412 status code indicates that one or more preconditions given in
1066   the request header fields evaluated to false when tested on the server.
1067   This response code allows the client to place preconditions on the
1068   current resource state (its current representations and metadata)
1069   and thus prevent the request method from being applied if the target
1070   resource is in an unexpected state.
1071</t>
1072</section>
1073</section>
1074
1075<section title="Precedence" anchor="precedence">
1076<t>
1077   When more than one conditional request header field is present in a request,
1078   the order in which the fields are evaluated becomes important. In practice,
1079   the fields defined in this document are consistently implemented in a
1080   single, logical order, due to the fact that entity tags are presumed to be
1081   more accurate than date validators. For example, the only reason to send
1082   both <x:ref>If-Modified-Since</x:ref> and <x:ref>If-None-Match</x:ref> in the same GET request is to
1083   support intermediary caches that might not have implemented <x:ref>If-None-Match</x:ref>,
1084   so it makes sense to ignore the <x:ref>If-Modified-Since</x:ref> when entity tags are
1085   understood and available for the selected representation.
1086</t>
1087<t>
1088   The general rule of conditional precedence is that exact match conditions
1089   are evaluated before cache-validating conditions and, within that order,
1090   last-modified conditions are only evaluated if the corresponding
1091   entity tag condition is not present (or not applicable because the
1092   selected representation does not have an entity tag).
1093</t>
1094<t>
1095   Specifically, the fields defined by this specification are evaluated
1096   as follows:
1097   <list style="numbers">
1098     <t>When <x:ref>If-Match</x:ref> is present, evaluate it:
1099       <list style="symbols">
1100         <t>if true, continue to step 3</t>
1101         <t>if false, respond <x:ref>412 (Precondition Failed)</x:ref></t>
1102       </list>
1103     </t>
1104     <t>When <x:ref>If-Match</x:ref> is not present and
1105        <x:ref>If-Unmodified-Since</x:ref> is present, evaluate it:
1106       <list style="symbols">
1107         <t>if true, continue to step 3</t>
1108         <t>if false, respond <x:ref>412 (Precondition Failed)</x:ref></t>
1109       </list>
1110     </t>
1111     <t>When the method is GET and both <x:ref>Range</x:ref> and
1112        <x:ref>If-Range</x:ref> are present, evaluate it:
1113       <list style="symbols">
1114         <t>if the validator matches, respond 206 (Partial Content)</t>
1115         <t>if the validator does not match, respond <x:ref>200 (OK)</x:ref></t>
1116       </list>
1117     </t>
1118     <t>When <x:ref>If-None-Match</x:ref> is present, evaluate it:
1119       <list style="symbols">
1120         <t>if true, all conditions are met</t>
1121         <t>if false for GET/HEAD, respond <x:ref>304 (Not Modified)</x:ref></t>
1122         <t>if false for other methods, respond <x:ref>412 (Precondition Failed)</x:ref></t>
1123       </list>
1124     </t>
1125     <t>When the method is GET or HEAD,
1126        <x:ref>If-None-Match</x:ref> is not present, and
1127        <x:ref>If-Modified-Since</x:ref> is present, evaluate it:
1128       <list style="symbols">
1129         <t>if true, all conditions are met</t>
1130         <t>if false, respond <x:ref>304 (Not Modified)</x:ref></t>
1131       </list>
1132     </t>
1133   </list>
1134</t>
1135<t>
1136   Any extension to HTTP/1.1 that defines additional conditional request
1137   header fields ought to define its own expectations regarding the order
1138   for evaluating such fields in relation to those defined in this document
1139   and other conditionals that might be found in practice.
1140</t>
1141</section>
1142
1143<section title="IANA Considerations" anchor="IANA.considerations">
1144
1145<section title="Status Code Registration" anchor="status.code.registration">
1146<t>
1147   The HTTP Status Code Registry located at <eref target="http://www.iana.org/assignments/http-status-codes"/>
1148   shall be updated with the registrations below:
1149</t>
1150<?BEGININC p4-conditional.iana-status-codes ?>
1151<!--AUTOGENERATED FROM extract-status-code-defs.xslt, do not edit manually-->
1152<texttable align="left" suppress-title="true" anchor="iana.status.code.registration.table">
1153   <ttcol>Value</ttcol>
1154   <ttcol>Description</ttcol>
1155   <ttcol>Reference</ttcol>
1156   <c>304</c>
1157   <c>Not Modified</c>
1158   <c>
1159      <xref target="status.304"/>
1160   </c>
1161   <c>412</c>
1162   <c>Precondition Failed</c>
1163   <c>
1164      <xref target="status.412"/>
1165   </c>
1166</texttable>
1167<!--(END)-->
1168<?ENDINC p4-conditional.iana-status-codes ?>
1169</section>
1170
1171<section title="Header Field Registration" anchor="header.field.registration">
1172<t>
1173   The Message Header Field Registry located at <eref target="http://www.iana.org/assignments/message-headers/message-header-index.html"/> shall be updated
1174   with the permanent registrations below (see <xref target="RFC3864"/>):
1175</t>
1176<?BEGININC p4-conditional.iana-headers ?>
1177<!--AUTOGENERATED FROM extract-header-defs.xslt, do not edit manually-->
1178<texttable align="left" suppress-title="true" anchor="iana.header.registration.table">
1179   <ttcol>Header Field Name</ttcol>
1180   <ttcol>Protocol</ttcol>
1181   <ttcol>Status</ttcol>
1182   <ttcol>Reference</ttcol>
1183
1184   <c>ETag</c>
1185   <c>http</c>
1186   <c>standard</c>
1187   <c>
1188      <xref target="header.etag"/>
1189   </c>
1190   <c>If-Match</c>
1191   <c>http</c>
1192   <c>standard</c>
1193   <c>
1194      <xref target="header.if-match"/>
1195   </c>
1196   <c>If-Modified-Since</c>
1197   <c>http</c>
1198   <c>standard</c>
1199   <c>
1200      <xref target="header.if-modified-since"/>
1201   </c>
1202   <c>If-None-Match</c>
1203   <c>http</c>
1204   <c>standard</c>
1205   <c>
1206      <xref target="header.if-none-match"/>
1207   </c>
1208   <c>If-Unmodified-Since</c>
1209   <c>http</c>
1210   <c>standard</c>
1211   <c>
1212      <xref target="header.if-unmodified-since"/>
1213   </c>
1214   <c>Last-Modified</c>
1215   <c>http</c>
1216   <c>standard</c>
1217   <c>
1218      <xref target="header.last-modified"/>
1219   </c>
1220</texttable>
1221<!--(END)-->
1222<?ENDINC p4-conditional.iana-headers ?>
1223<t>
1224   The change controller is: "IETF (iesg@ietf.org) - Internet Engineering Task Force".
1225</t>
1226</section>
1227</section>
1228
1229<section title="Security Considerations" anchor="security.considerations">
1230<t>
1231   No additional security considerations have been identified beyond
1232   those applicable to HTTP in general &messaging;.
1233</t>
1234<t>
1235   The validators defined by this specification are not intended to ensure
1236   the validity of a representation, guard against malicious changes, or
1237   detect man-in-the-middle attacks. At best, they enable more efficient cache
1238   updates and optimistic concurrent writes when all participants are behaving
1239   nicely. At worst, the conditions will fail and the client will receive a
1240   response that is no more harmful than an HTTP exchange without conditional
1241   requests.
1242</t>
1243</section>
1244
1245<section title="Acknowledgments" anchor="acks">
1246<t>
1247  See &acks;.
1248</t>
1249</section>
1250</middle>
1251<back>
1252
1253<references title="Normative References">
1254
1255<reference anchor="Part1">
1256  <front>
1257    <title>HTTP/1.1, part 1: URIs, Connections, and Message Parsing</title>
1258    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
1259      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
1260      <address><email>fielding@gbiv.com</email></address>
1261    </author>
1262    <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
1263      <organization abbrev="W3C">World Wide Web Consortium</organization>
1264      <address><email>ylafon@w3.org</email></address>
1265    </author>
1266    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
1267      <organization abbrev="greenbytes">greenbytes GmbH</organization>
1268      <address><email>julian.reschke@greenbytes.de</email></address>
1269    </author>
1270    <date month="&ID-MONTH;" year="&ID-YEAR;"/>
1271  </front>
1272  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p1-messaging-&ID-VERSION;"/>
1273  <x:source href="p1-messaging.xml" basename="p1-messaging"/>
1274</reference>
1275
1276<reference anchor="Part2">
1277  <front>
1278    <title>HTTP/1.1, part 2: Message Semantics, Payload and Content Negotiation</title>
1279    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
1280      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
1281      <address><email>fielding@gbiv.com</email></address>
1282    </author>
1283    <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
1284      <organization abbrev="W3C">World Wide Web Consortium</organization>
1285      <address><email>ylafon@w3.org</email></address>
1286    </author>
1287    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
1288      <organization abbrev="greenbytes">greenbytes GmbH</organization>
1289      <address><email>julian.reschke@greenbytes.de</email></address>
1290    </author>
1291    <date month="&ID-MONTH;" year="&ID-YEAR;"/>
1292  </front>
1293  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p2-semantics-&ID-VERSION;"/>
1294  <x:source href="p2-semantics.xml" basename="p2-semantics">
1295    <x:defines>2xx</x:defines>
1296    <x:defines>2xx (Successful)</x:defines>
1297    <x:defines>200 (OK)</x:defines>
1298    <x:defines>Accept-Encoding</x:defines>
1299    <x:defines>Content-Location</x:defines>
1300    <x:defines>Content-Type</x:defines>
1301    <x:defines>Date</x:defines>
1302    <x:defines>Location</x:defines>
1303  </x:source>
1304</reference>
1305
1306<reference anchor="Part5">
1307  <front>
1308    <title>HTTP/1.1, part 5: Range Requests and Partial Responses</title>
1309    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
1310      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
1311      <address><email>fielding@gbiv.com</email></address>
1312    </author>
1313    <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
1314      <organization abbrev="W3C">World Wide Web Consortium</organization>
1315      <address><email>ylafon@w3.org</email></address>
1316    </author>
1317    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
1318      <organization abbrev="greenbytes">greenbytes GmbH</organization>
1319      <address><email>julian.reschke@greenbytes.de</email></address>
1320    </author>
1321    <date month="&ID-MONTH;" year="&ID-YEAR;"/>
1322  </front>
1323  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p5-range-&ID-VERSION;"/>
1324  <x:source href="p5-range.xml" basename="p5-range">
1325    <x:defines>If-Range</x:defines>
1326    <x:defines>Range</x:defines>
1327  </x:source>
1328</reference>
1329
1330<reference anchor="Part6">
1331  <front>
1332    <title>HTTP/1.1, part 6: Caching</title>
1333    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
1334      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
1335      <address><email>fielding@gbiv.com</email></address>
1336    </author>
1337    <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
1338      <organization abbrev="W3C">World Wide Web Consortium</organization>
1339      <address><email>ylafon@w3.org</email></address>
1340    </author>
1341    <author initials="M." surname="Nottingham" fullname="Mark Nottingham" role="editor">
1342      <organization>Rackspace</organization>
1343      <address><email>mnot@mnot.net</email></address>
1344    </author>
1345    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
1346      <organization abbrev="greenbytes">greenbytes GmbH</organization>
1347      <address><email>julian.reschke@greenbytes.de</email></address>
1348    </author>
1349    <date month="&ID-MONTH;" year="&ID-YEAR;"/>
1350  </front>
1351  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p6-cache-&ID-VERSION;"/>
1352  <x:source href="p6-cache.xml" basename="p6-cache">
1353    <x:defines>Cache-Control</x:defines>
1354    <x:defines>Expires</x:defines>
1355    <x:defines>Vary</x:defines>
1356  </x:source>
1357</reference>
1358
1359<reference anchor="RFC2119">
1360  <front>
1361    <title>Key words for use in RFCs to Indicate Requirement Levels</title>
1362    <author initials="S." surname="Bradner" fullname="Scott Bradner">
1363      <organization>Harvard University</organization>
1364      <address><email>sob@harvard.edu</email></address>
1365    </author>
1366    <date month="March" year="1997"/>
1367  </front>
1368  <seriesInfo name="BCP" value="14"/>
1369  <seriesInfo name="RFC" value="2119"/>
1370</reference>
1371
1372<reference anchor="RFC5234">
1373  <front>
1374    <title abbrev="ABNF for Syntax Specifications">Augmented BNF for Syntax Specifications: ABNF</title>
1375    <author initials="D." surname="Crocker" fullname="Dave Crocker" role="editor">
1376      <organization>Brandenburg InternetWorking</organization>
1377      <address>
1378        <email>dcrocker@bbiw.net</email>
1379      </address> 
1380    </author>
1381    <author initials="P." surname="Overell" fullname="Paul Overell">
1382      <organization>THUS plc.</organization>
1383      <address>
1384        <email>paul.overell@thus.net</email>
1385      </address>
1386    </author>
1387    <date month="January" year="2008"/>
1388  </front>
1389  <seriesInfo name="STD" value="68"/>
1390  <seriesInfo name="RFC" value="5234"/>
1391</reference>
1392
1393</references>
1394
1395<references title="Informative References">
1396
1397<reference anchor="RFC2616">
1398  <front>
1399    <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
1400    <author initials="R." surname="Fielding" fullname="R. Fielding">
1401      <organization>University of California, Irvine</organization>
1402      <address><email>fielding@ics.uci.edu</email></address>
1403    </author>
1404    <author initials="J." surname="Gettys" fullname="J. Gettys">
1405      <organization>W3C</organization>
1406      <address><email>jg@w3.org</email></address>
1407    </author>
1408    <author initials="J." surname="Mogul" fullname="J. Mogul">
1409      <organization>Compaq Computer Corporation</organization>
1410      <address><email>mogul@wrl.dec.com</email></address>
1411    </author>
1412    <author initials="H." surname="Frystyk" fullname="H. Frystyk">
1413      <organization>MIT Laboratory for Computer Science</organization>
1414      <address><email>frystyk@w3.org</email></address>
1415    </author>
1416    <author initials="L." surname="Masinter" fullname="L. Masinter">
1417      <organization>Xerox Corporation</organization>
1418      <address><email>masinter@parc.xerox.com</email></address>
1419    </author>
1420    <author initials="P." surname="Leach" fullname="P. Leach">
1421      <organization>Microsoft Corporation</organization>
1422      <address><email>paulle@microsoft.com</email></address>
1423    </author>
1424    <author initials="T." surname="Berners-Lee" fullname="T. Berners-Lee">
1425      <organization>W3C</organization>
1426      <address><email>timbl@w3.org</email></address>
1427    </author>
1428    <date month="June" year="1999"/>
1429  </front>
1430  <seriesInfo name="RFC" value="2616"/>
1431</reference>
1432
1433<reference anchor='RFC3864'>
1434  <front>
1435    <title>Registration Procedures for Message Header Fields</title>
1436    <author initials='G.' surname='Klyne' fullname='G. Klyne'>
1437      <organization>Nine by Nine</organization>
1438      <address><email>GK-IETF@ninebynine.org</email></address>
1439    </author>
1440    <author initials='M.' surname='Nottingham' fullname='M. Nottingham'>
1441      <organization>BEA Systems</organization>
1442      <address><email>mnot@pobox.com</email></address>
1443    </author>
1444    <author initials='J.' surname='Mogul' fullname='J. Mogul'>
1445      <organization>HP Labs</organization>
1446      <address><email>JeffMogul@acm.org</email></address>
1447    </author>
1448    <date year='2004' month='September' />
1449  </front>
1450  <seriesInfo name='BCP' value='90' />
1451  <seriesInfo name='RFC' value='3864' />
1452</reference>
1453
1454<reference anchor='RFC4918'>
1455  <front>
1456    <title>HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)</title>
1457    <author initials="L.M." surname="Dusseault" fullname="Lisa Dusseault" role="editor" >
1458      <organization abbrev="CommerceNet">CommerceNet</organization>
1459      <address><email>ldusseault@commerce.net</email></address>
1460    </author>
1461    <date month="June" year="2007" />
1462  </front>
1463  <seriesInfo name='RFC' value='4918' />
1464</reference>
1465</references>
1466
1467<section title="Changes from RFC 2616" anchor="changes.from.rfc.2616">
1468<t>
1469  Allow weak entity-tags in all requests except range requests (Sections
1470  <xref target="weak.and.strong.validators" format="counter"/> and
1471  <xref target="header.if-none-match" format="counter"/>).
1472</t>
1473<t>
1474  Change <x:ref>ETag</x:ref> header field ABNF not to use quoted-string, thus
1475  avoiding escaping issues.
1476  (<xref target="header.etag"/>)
1477</t>
1478<t>
1479  Change ABNF productions for header fields to only define the field value.
1480  (<xref target="header.field.definitions"/>)
1481</t>
1482</section>
1483
1484<?BEGININC p4-conditional.abnf-appendix ?>
1485<section xmlns:x="http://purl.org/net/xml2rfc/ext" title="Collected ABNF" anchor="collected.abnf">
1486<figure>
1487<artwork type="abnf" name="p4-conditional.parsed-abnf">
1488<x:ref>ETag</x:ref> = entity-tag
1489
1490<x:ref>HTTP-date</x:ref> = &lt;HTTP-date, defined in [Part2], Section 5.1&gt;
1491
1492<x:ref>If-Match</x:ref> = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
1493 entity-tag ] ) )
1494<x:ref>If-Modified-Since</x:ref> = HTTP-date
1495<x:ref>If-None-Match</x:ref> = "*" / ( *( "," OWS ) entity-tag *( OWS "," [ OWS
1496 entity-tag ] ) )
1497<x:ref>If-Unmodified-Since</x:ref> = HTTP-date
1498
1499<x:ref>Last-Modified</x:ref> = HTTP-date
1500
1501<x:ref>OWS</x:ref> = &lt;OWS, defined in [Part1], Section 3.2.1&gt;
1502
1503<x:ref>entity-tag</x:ref> = [ weak ] opaque-tag
1504<x:ref>etagc</x:ref> = "!" / %x23-7E ; '#'-'~'
1505 / obs-text
1506
1507<x:ref>obs-text</x:ref> = &lt;obs-text, defined in [Part1], Section 3.2.4&gt;
1508<x:ref>opaque-tag</x:ref> = DQUOTE *etagc DQUOTE
1509
1510<x:ref>weak</x:ref> = %x57.2F ; W/
1511</artwork>
1512</figure>
1513</section>
1514<?ENDINC p4-conditional.abnf-appendix ?>
1515
1516<section title="Change Log (to be removed by RFC Editor before publication)" anchor="change.log">
1517<t>
1518  Changes up to the first Working Group Last Call draft are summarized
1519  in <eref target="http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional-19#appendix-C"/>.
1520</t>
1521
1522<section title="Since draft-ietf-httpbis-p4-conditional-19" anchor="changes.since.19">
1523<t>
1524  Closed issues:
1525  <list style="symbols"> 
1526    <t>
1527      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/241"/>:
1528      "Need to clarify eval order/interaction of conditional headers"
1529    </t>
1530    <t>
1531      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/354"/>:
1532      "ETags and Conditional Requests"
1533    </t>
1534    <t>
1535      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/361"/>:
1536      "ABNF requirements for recipients"
1537    </t>
1538    <t>
1539      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/363"/>:
1540      "Rare cases"
1541    </t>
1542    <t>
1543      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/365"/>:
1544      "Conditional Request Security Considerations"
1545    </t>
1546    <t>
1547      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/371"/>:
1548      "If-Modified-Since lacks definition for method != GET"
1549    </t>
1550    <t>
1551      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/372"/>:
1552      "refactor conditional header field descriptions"
1553    </t>
1554  </list>
1555</t>
1556</section>
1557
1558</section>
1559
1560</back>
1561</rfc>
Note: See TracBrowser for help on using the repository browser.