Revision 1085995 of HEAD

  • Revision slug: Web/HTTP/Methods/HEAD
  • Revision title: HEAD
  • Revision id: 1085995
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment First version done

Revision Content

{{HTTPSidebar}}

The HEAD method requests the headers that would be returned if the specified resource would be done with a {{HTTPMethod("GET")}}. Such a request can be done before deciding to download a large resource to save bandwidth.

A response to a HEAD method should not have a body. If so, it must be ignored. {{glossary("Entity header", "Entity headers")}} may be included or not in the response; if they are, they relate to the body a {{HTTPMethod("GET")}} method would have returned in its response, not to the body of the HEAD response.

If the result of a HEAD requests shows that a resource cached after a {{HTTPMethod("GET")}} request is now outdate, the cache is invalidated, even if no GET method has been done.

Request has body No
Response has body No
{{Glossary("Safe")}} Yes
{{Glossary("Idempotent")}} Yes
{{Glossary("Cacheable")}} Yes
Allowed in HTML forms No

Syntax

HEAD /index.html

Specifications

Specification Title
{{RFC("7231")}} Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

Browser compatibility

{{Compat}}

See also

  • {{HTTPMethod("Get")}}

Revision Source

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

<p>The <code>HEAD</code> method requests the headers that would be returned if the specified resource would be done with a {{HTTPMethod("GET")}}. Such a request can be done before deciding to download a large resource to save bandwidth.</p>

<p>A response to a <code>HEAD</code> method should not have a body. If so, it must be ignored. {{glossary("Entity header", "Entity headers")}} may be included or not in the response; if they are, they relate to the body a {{HTTPMethod("GET")}} method would have returned in its response, not to the body of the <code>HEAD</code> response.</p>

<p>If the result of a <code>HEAD</code> requests shows that a resource cached after a {{HTTPMethod("GET")}} request is now outdate, the cache is invalidated, even if no <code>GET</code> method has been done.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Request has body</th>
   <td>No</td>
  </tr>
  <tr>
   <th scope="row">Response has body</th>
   <td>No</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Safe")}}</th>
   <td>Yes</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Idempotent")}}</th>
   <td>Yes</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Cacheable")}}</th>
   <td>Yes</td>
  </tr>
  <tr>
   <th scope="row">Allowed in HTML forms</th>
   <td>No</td>
  </tr>
 </tbody>
</table>

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

<pre class="syntaxbox">
HEAD /index.html
</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("7231")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
  </tr>
 </tbody>
</table>

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

<p class="hidden">To contribute to this compatibility data, please write a pull request against this file: <a href="https://github.com/mdn/browser-compat-data/blob/master/http/methods.json">https://github.com/mdn/browser-compat-data/blob/master/http/methods.json</a>.</p>

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

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

<ul>
 <li>{{HTTPMethod("Get")}}</li>
</ul>
Revert to this revision