Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

What does the HEAD method return, and how does it differ from GET?

Quick answer

A HEAD request asks for the response headers a GET request would provide, but not the response content. Use it when you need to inspect metadata, such as Content-Length, without asking for the content itself. A successful HEAD response has no body; if a server sends one anyway, clients should ignore it. Server behavior can affect what you observe, so check the actual response when troubleshooting. [S1]

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

What does the HEAD method return, and how is that different from GET? I want to check a resource without retrieving its content.

Geez

HEAD asks for response metadata in headers, as GET would, but without the response content. GET requests the resource content as well as its response headers. For example, a client might use HEAD to inspect a Content-Length header before deciding whether to download a resource. [S1]

The key distinction is the response body: a successful HEAD response has no body. If a server does send one, the client should ignore it. [S1] HEAD is therefore useful for checking headers, but it is not a way to preview or retrieve the content.

Follow-up question

Can you show the difference as an HTTP exchange? A short example would help me recognize which part is the body.

Geez

Here is an illustrative comparison. The resource path and values are placeholders; the example shows the intended shape, not a promise that every server will return these exact headers.

HEAD request: HEAD /files/report.pdf HTTP/1.1 Host: example.invalid

Illustrative response: HTTP/1.1 200 OK Content-Length: 84000 Content-Type: application/pdf

[No response body]

GET request: GET /files/report.pdf HTTP/1.1 Host: example.invalid

Illustrative response: HTTP/1.1 200 OK Content-Length: 84000 Content-Type: application/pdf

[Response content would follow]

The header lines describe the response; the content after the blank line is the body. For a successful HEAD response, that body is absent. The listed values are made-up examples, not measured results. [S1]

Follow-up question

When should I choose HEAD, and what should I do if what I observe does not match the comparison?

Geez

Choose HEAD when your task is to inspect response headers—for instance, to check whether a Content-Length value is present before requesting the content. Choose GET when you need the resource content itself. [S1]

If a HEAD request appears to return content, do not treat that content as a usable HEAD result: the stated semantics are that a successful response has no body, and a client should ignore a body if one is sent. [S1] The source describes intended behavior and notes that server behavior can affect what a client observes; it does not establish that every server will behave identically or that a particular header will always be present. [S1]

For a practical comparison, record the method, request path, status line, response headers, and whether a body was observed. If the result matters for your application, compare HEAD and GET against the same resource and note the actual responses rather than assuming the example values apply.

Follow-up question

Can you give me a reusable checklist for choosing and checking the method?

Geez

Yes. Start by deciding whether you need response metadata or the resource content: use HEAD for metadata and GET when you need the content. Record the request method and path, then note the status and headers actually returned, including Content-Length if present. For a successful HEAD response, expect no body; ignore any body a server sends. If behavior is unexpected, check the actual response rather than relying on the illustrative example. [S1]

The checklist below turns those steps into a quick reference.

A practical checklist

  • Decide whether you need metadata or resource content.

  • Use HEAD to inspect response headers; use GET when you need the content.

  • Record the request method and resource path.

  • Note the status and headers actually returned, including Content-Length if present.

  • Treat a successful HEAD response as bodyless; ignore any body a server sends.

A few more useful answers

Does HEAD return the resource content?

No. It asks for response headers without the response content. A successful HEAD response has no body; if a server sends one, it should be ignored. [S1]

Can I use HEAD to inspect Content-Length?

Yes, a client can use HEAD to inspect metadata such as Content-Length before downloading a resource. The header’s presence or value is not guaranteed by this example. [S1]

Will every server behave exactly like the comparison?

Not necessarily. The semantics describe the intended response, while server behavior may affect what a client observes; check the actual response when troubleshooting. [S1]

Sources

References used for this guide.

  1. [S1] HEAD request method - HTTP | MDN
    developer.mozilla.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work