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

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

record issue status

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