14 October 2018

what is HTTP HEAD request?

Off late REST services have become very popular. People pays lot of attention to HTTP verbs while desiging the REST services. There are different HTTP verbs meant for different kinds of HTTP requests, namely GET, POST, PUT, DELETE, PATCH, HEAD, etc.

In this post let’s discuss perticulalry on HTTP HEAD requests and when to use them.

What is HTTP HEAD requests?

With HTTP Head requests (as the name already implying) server will return only the HTTP Headers but not the body.

When to use HTTP HEAD then?

Responses for the Http Head request from the servers will be light weight compared to HTTP GET requests, because they don’t contain any body. So you can use HTTP HEAD request / response together to determine whether a heavy payload entity is modified at the server end or not.

One example the server can just return when was a requested resource last modified with the HTTP HEAD response, then client will verify to see if the version of the entity it possess alrerady is latest or not.

If the entity is latest, then client can continue to use the entity it has in its store, else it can issue a HTTP GET request to fetch the heavy payload entity from the server.

In this way using the HTTP HEAD request and responses between client and servers we can design more performant systems by avoiding exchange of heavy payload object when not really required.