Is the HTTP 'HEAD' verb useful in web development?

HttpHttpverbs

Http Problem Overview


I've read the w3.org spec on the 'HEAD' verb, and I guess I'm missing something. I can't see how it would be useful.

Is the HTTP 'HEAD' verb useful in web development?

If so, how?

Http Solutions


Solution 1 - Http

From RFC2616:

> This method (HEAD) can be used for obtaining > metainformation about the entity > implied by the request without > transferring the entity-body itself. > This method is often used for testing > hypertext links for validity, > accessibility, and recent > modification.

The reason why HEAD is preferred to GET is due to the absence of the message body in the response making it using in scenarios where you want to determine if the content has changed at all - a change in the last modified time or content length usually signifies this.

Also, a HEAD request will provide some information about the server setup (whether it is IIS/Apache etc.), unless the server was masked; of course, this is available in all responses, but HEAD is preferred especially when you don't know the size of the response. HEAD is also the easiest way to determine if a site is up or down; again the irrelevance of the message body makes HEAD the ideal candidate.

I'm not sure about this, but RSS/ATOM feed readers would use HEAD over GET to ascertain if the contents of the feed have changed.

Solution 2 - Http

The HTTP HEAD can also be used to pre-authenticate to web server, before you do HTTP PUT/POST of some large data. Without the first HEAD request, you would be sending the large data to web server twice (because the first request would return 401 unauthorized reponse with WWW-authenticate header).

Solution 3 - Http

It's mainly for browsers and proxies to determine whether they can use a cached copy of the web document without having to download the whole thing (which would rather defeat the purpose of a cache).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDan EsparzaView Question on Stackoverflow
Solution 1 - HttpVineet ReynoldsView Answer on Stackoverflow
Solution 2 - HttpPeter SladekView Answer on Stackoverflow
Solution 3 - HttpchaosView Answer on Stackoverflow