Revision 1104615 of If-None-Match

  • Revision slug: Web/HTTP/Headers/If-None-Match
  • Revision title: If-None-Match
  • Revision id: 1104615
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment WIP

Revision Content

{{HTTPSidebar}}

The If-None-Match request HTTP header makes the request conditional. For {{HTTPMethod("GET")}} and {{HTTPMethod("HEAD")}} methods, the server will send back the requested resource, with a {{HTTPStatus("200")}} status, only if doesn't have a {{HTTPHeader("ETag")}} matching the one given. For other methods, the request will be processed only if the eventually existing resource's {{HTTPHeader("ETag")}} doesn't match any of the value listed.

Comparison with the stored {{HTTPHeader("ETag")}} uses the weak comparison algorithm, meaning two files are considered identical not only if they are identical byte to byte, but if the content is equivalent. For example, two pages that would differ only by the date of generation in the footer would be considered as identical.

When used in combination with {{HTTPHeader("If-Modified-Since")}}, it has precedence (if the server support it).

There are two common use cases:

  • For {{HTTPMethod("GET")}} and {{HTTPMethod("HEAD")}} methods, to update a cached entity that has an associated {{HTTPHeader("ETag")}}.
  • For other methods, and in particular for {{HTTPMethod("PUT")}}, If-None-Match used with the * value can be used to save a file not known to exist, guaranteeing that another upload didn't happen before, losing the data of the previous put; this problems is the variation of the lost update problem.
Header type {{Glossary("Request header")}}
{{Glossary("Forbidden header name")}} no

Syntax

If-None-Match: <etag_value>
If-None-Match: <etag_value>, <etag_value>, <etag_value>
If-None-Match: *

Directives

 

Examples

If-None-Match: "bfc13a64729c4290ef5b2c2730249c88ca92d82d"

Specifications

Specification Title
{{RFC("7232", "If-None-Match", "3.2")}} Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests

Browser compatibility

{{Compat}}

See also

  • {{HTTPHeader("ETag")}}
  • {{HTTPHeader("If-Unmodified-Since")}}
  • {{HTTPHeader("If-Modified-Since")}}
  • {{HTTPHeader("If-Match")}}
  • {{HTTPStatus("304")}} Not Modified
  • {{HTTPStatus("412")}} Precondition Failed

Revision Source

<div>{{HTTPSidebar}}</div>

<p>The <strong><code>If-None-Match</code></strong> request HTTP header makes the request conditional. For {{HTTPMethod("GET")}} and {{HTTPMethod("HEAD")}} methods, the server will send back the requested resource, with a {{HTTPStatus("200")}} status, only if doesn't have a {{HTTPHeader("ETag")}} matching the one given. For other methods, the request will be processed only if the eventually existing resource's {{HTTPHeader("ETag")}} doesn't match any of the value listed.</p>

<p>Comparison with the stored {{HTTPHeader("ETag")}} uses the <em>weak comparison algorithm</em>, meaning two files are considered identical not only if they are identical byte to byte, but if the content is equivalent. For example, two pages that would differ only by the date of generation in the footer would be considered as identical.</p>

<p>When used in combination with {{HTTPHeader("If-Modified-Since")}}, it has precedence (if the server support it).</p>

<p>There are two common use cases:</p>

<ul>
 <li>For {{HTTPMethod("GET")}} and {{HTTPMethod("HEAD")}} methods, to update a cached entity that has an associated {{HTTPHeader("ETag")}}.</li>
 <li>For other methods, and in particular for {{HTTPMethod("PUT")}}, <code>If-None-Match</code> used with the <code>*</code> value can be used to save a file not known to exist, guaranteeing that another upload didn't happen before, losing the data of the previous put; this problems is the variation of the <a href="https://www.w3.org/1999/04/Editing/#3.1">lost update problem</a>.</li>
</ul>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Request header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>no</td>
  </tr>
 </tbody>
</table>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
If-None-Match: &lt;etag_value&gt;
If-None-Match: &lt;etag_value&gt;, &lt;etag_value&gt;, &lt;etag_value&gt;
If-None-Match: *</pre>

<h2 id="Directives">Directives</h2>

<p>&nbsp;</p>

<h2 id="Examples">Examples</h2>

<pre>
If-None-Match: "bfc13a64729c4290ef5b2c2730249c88ca92d82d"
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Title</th>
  </tr>
  <tr>
   <td>{{RFC("7232", "If-None-Match", "3.2")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you’d like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data/README.md">https://github.com/mdn/browser-compat-data/README.md</a> and send us a pull request.</p>

<p>{{Compat}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{HTTPHeader("ETag")}}</li>
 <li>{{HTTPHeader("If-Unmodified-Since")}}</li>
 <li>{{HTTPHeader("If-Modified-Since")}}</li>
 <li>{{HTTPHeader("If-Match")}}</li>
 <li>{{HTTPStatus("304")}}<code> Not Modified</code></li>
 <li>{{HTTPStatus("412")}}<code> Precondition Failed</code></li>
</ul>
Revert to this revision