HEAD

HTTP HEAD

SafeYes
IdempotentYes
CacheableYes
Request bodyNo
Response bodyNo

Overview

HEAD behaves exactly like GET but returns only headers, without a body. It is handy for checking a file's size, type, modification time, or existence without actually downloading it.

Details

It is often used to check size via `Content-Length` before a download, or to validate caches via `ETag`/`Last-Modified`. It also works well as a lightweight liveness check (200/404) for a link.

The server must compute the same headers as GET but omit the body. Static servers handle this automatically, but when writing a dynamic handler, branch so HEAD does not build a body — saving needless work.

Request / Response example

Request
HEAD /downloads/app.zip HTTP/1.1
Host: example.com
Response
HTTP/1.1 200 OK
Content-Length: 10485760
Content-Type: application/zip
Accept-Ranges: bytes

In code

curl -I https://example.com/downloads/app.zip
const res = await fetch('/downloads/app.zip', { method: 'HEAD' });
const size = res.headers.get('Content-Length');

Common mistakes

Typical status codes

Related methods

Related headers