Technical Reports from the Front Lines of Software & Systems.

HTTP HEAD is an HTTP method used to retrieve metadata about a resource without returning the resource itself. This can be useful to retrieve information about a resource without having to download the entire resource.

The HEAD method is identical to the GET method, except that it does not return the resource body. Instead, it returns only the resource’s HTTP headers. These headers can include information such as the resource’s content type, content length, and last modified date.

GET is like a movie because it is the full content that you are requesting. HEAD is like the preview because it is a smaller amount of content that gives you an idea of what the full content is like. The preview gives you an idea what the movie is about and entices you to head to the theaters!

One of the requirements from the HTTP/1.1 Semantics and Content RFC 7231 is that when a HEAD request is made, the server should send the same header fields in the response as it would have if the request had been a GET. So, if a GET request would have returned a 204 status code, then the HEAD request must also return a 204 status code.

One common use for the HEAD method is to check if a resource has been updated since the last time it was accessed. This can be done by comparing the value of the Last-Modified header to the previously cached value. If the resource has been updated, the new headers will be returned and can be used to fetch the updated resource.

Amazon uses HEAD to retrieve the metadata for an S3 object, Github uses it to retrieve information about a specific file or directory and Facebook uses it to check if a user’s profile picture exists before fetching it. This allows Facebook to avoid fetching pictures that don’t exist, which can save time and bandwidth.

HTTP HEAD plays a crucial role in web communication and is a tool that should not be overlooked. Utilizing this method in web requests can greatly improve efficiency and speed. Understanding how HTTP HEAD works and incorporating it into your web projects can make a significant impact on your website’s performance. Don’t hesitate to dive deeper into this lesser-known HTTP method and unlock its full potential for your web communication needs.

Leave a comment