Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HEAD request vs. GET request

I always had the idea that doing a HEAD request instead of a GET request was faster (no matter the size of the resource) and therefore had it advantages in certain solutions.

However, while making a HEAD request in Python (to a 5+ MB dynamic generated resource) I realized that it took the same time as making a GET request (almost 27 seconds instead of the 'less than 2 seconds' I was hoping for).

Used some urllib2 solutions to make a HEAD request found here and even used pycurl (setting headers and nobody to True). Both of them took the same time.

Am I missing something conceptually? is it possible, using Python, to do a 'quick' HEAD request?

like image 853
Ben Avatar asked Jan 19 '23 11:01

Ben


1 Answers

The server is taking the bulk of the time, not your requester or the network. If it's a dynamic resource, it's likely that the server doesn't know all the header information - in particular, Content-Length - until it's built it. So it has to build the whole thing whether you're doing HEAD or GET.

like image 94
Russell Borogove Avatar answered Jan 30 '23 01:01

Russell Borogove