Wednesday, 12 March 2014

HTTP Method - HEAD

🚀 Boost your web architecture and backend knowledge!

🔔 Subscribe to Ram N Java on YouTube

What Is the HTTP HEAD Method?

In web communications, a client (like a browser or an automated crawler) communicates with a server hosting websites and web APIs.

The HTTP HEAD method requests the exact same response headers and status line as a standard GET request, but without the response body. Instead of downloading the actual file content, it retrieves only metadata describing that resource.

Why Use HTTP HEAD Instead of GET?

Because the server returns only the status line and headers without transmitting any message body, the HEAD method offers several major advantages:

  • Significantly Faster & Bandwidth-Friendly: Avoids loading large files across the network when you only need to inspect headers.
  • Efficient Caching Validation: Checks headers such as Last-Modified or ETag to see if a cached document has changed before downloading the whole file again with GET.
  • URL & Resource Validation: Verifies whether a resource exists and checks its size (Content-Length) or format (Content-Type) before fetching it.

Sample HTTP HEAD Request & Response

Here is an example of what an HTTP HEAD request sent from a client looks like:

HEAD /hello.htm HTTP/1.1
Host: www.ramnjava.blogspot.com

The server processes the request and returns only the status line and header details, with no body:

HTTP/1.1 200 OK
Date: Mon, 10 Mar 2026 12:00:00 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Mon, 10 Mar 2026 11:30:00 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed

Related Tutorials You Might Enjoy


Click here to watch in Youtube : https://www.youtube.com/watch?v=AJXO-JpKPCw

Click the below Image to Enlarge
HTTP Method - HEAD
HTTP Method - HEAD
HTTP Method - HEAD

See also:

  • Servlets Tutorial
  • All Design Patterns Links
  • 2 comments:

    Tutorials