Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP HEAD vs GET - huge speed difference?

Status
Not open for further replies.

cgfiws

Programmer
Feb 2, 2003
1
NZ
Hi there,

I'm building a dead link report script, and I'm at the point of optimising it, and I've come across what seems to be a very weird situation. The exact HTTP query being used is:

$method $path HTTP/1.1\r\nHost: $purl[host]\r\nUser-Agent: PHP\r\n\r\n

Where $method is either GET or HEAD and path is the path.

I use the GET method only when a server won't respond to a HEAD request. The script as a whole's been running slowly, so I ran a profiler over it, and the two relevant lines from that output are:

Code:
f-Calls  Time           % of Total  Timer Name
 25      1820.9293 ms   (  0.68 %)  get_url_status_code_get
665      255921.7318 ms ( 95.03 %)  get_url_status_code_head

This makes using a GET query about 7 times as fast as a head query (on a per function call basis)... obviously I can change it to use GET all the time, but I would have expected exactly the opposite result - since GET returns much more data than HEAD right?

Any comments, suggestions or wisdom I might apply to this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top