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

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

improve introduction of list operator (see #542)

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