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.
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.
HEAD /downloads/app.zip HTTP/1.1
Host: example.comHTTP/1.1 200 OK
Content-Length: 10485760
Content-Type: application/zip
Accept-Ranges: bytescurl -I https://example.com/downloads/app.zipconst res = await fetch('/downloads/app.zip', { method: 'HEAD' });
const size = res.headers.get('Content-Length');