About1
The HEAD
HTTP method
requests the metadata of a resource in the form of headers that the server would have sent if the GET method
was used instead.
This method can be used in cases where a URL might produce a large download, e.g. a HEAD
request can read the Content-Length header to check the
file size before downloading the file with a GET
. If the response to a HEAD
request shows that a cached URL response is now outdated, the cached copy
is invalidated even if no GET
request was made.
Characteristics
Request has body | Successful response has body | Safe | Idempotent | Cacheable | Allowed in HTML forms |
---|---|---|---|---|---|
No | No | Yes | Yes | Yes | No |
Syntax
HEAD <request-target>["?"<query>] HTTP/1.1
<request-target>
: identifies the target resource of the request when combined with the information provided in the
Host header. This is an absolute path (e.g. /path/to/file.html
) in requests to an origin server, and an absolute URL
in requests to proxies (e.g. http://www.example.com/path/to/file.html
)
<query>
(Optional) - an optional query component preceded by a question-mark?
. Often used to carry identifying
information in the form of key=value
pairs.
Examples
Successfully retrieving resource metadata
The following curl
command creates a HEAD
request for example.com
:
curl --head example.com
This is equivalent to a GET
request, except the server shouldn’t include a message body in the response. It creates an HTTP request
that looks like this:
HEAD / HTTP/1.1
Host: example.com
User-Agent: curl/8.6.0
Accept: */*
The server sends back a 200 Ok response comprised only of headers. The response is effectively metadata that describes the resource of the resource itself (some caching headers are omitted in this example for brevity):
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Date Tue, 06 May 2025 21:02:00 GMT
Content-Length: 1234567
Anki
Links
References
MDN. “HEAD”. Available at: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods/HEAD . (Accessed: ). ↩︎