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

Last change on this file since 2704 was 2681, checked in by julian.reschke@…, 6 years ago

minor editorial changes (#553)

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