API Fundamentals Course
API Fundamentals
/
Advanced

HEAD

Definition

An HTTP method identical to GET, except the server must NOT return a message body in the response. It is used strictly to read the response headers.

Explain Like I'm New

Imagine you want to download a massive 50 Gigabyte video file, but you only have 2 GB of space on your hard drive. If you send a GET request, the server starts sending 50GB of data. If you send a HEAD request, the server just sends the Headers (which includes `Content-Length: 50GB`). You read the header, realize it's too big, and cancel.

Real World Example

Checking if a URL is valid (returns a 200) without actually downloading the entire webpage. Checking if an image has been modified recently before downloading it again.

Common Use Cases

  • •Bandwidth saving
  • •Link validation
  • •Cache validation

Interactive Example

Loading...
Console output will appear here...

Interview Questions

basic

  • What is the exact difference between a GET request and a HEAD request?

intermediate

  • Can a HEAD request modify data in the database?

Flash Cards

Question

Difference?

Click to reveal answer
Answer

The server's response to a HEAD request contains Headers, but absolutely no Body payload.

Question

Modify database?

Click to reveal answer
Answer

No. Like GET, HEAD is defined as a 'Safe' method. It must only be used for retrieval.