source: draft-ietf-httpbis/20/p4-conditional.xml @ 1807

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

Prepare release of -20 drafts

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