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

Last change on this file since 2586 was 2569, checked in by fielding@…, 7 years ago

(editorial) OWASP only provides useful additional info for web application semantics and authentication; see #520 and #549

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