-
October 9th, 2009, 01:49 PM
#1
Why does first ever HttpSendRequest take longer?
I promise this isn't as simple as it sounds. I'm wondering why the the first ever call to HttpSendRequest takes much longer than subsequent calls, even when the later requests are for a different URL. For example:
InternetConnect(... "foo.com" ...) // returns immediately
HttpOpenRequest(...) // returns immediately
HttpSendRequest(...) // takes ~3 sec
HttpSendRequest(...) // takes ~200 ms
InternetConnect(... "bar.com" ...) // returns immediately
HttpOpenRequest(...) // returns immediately
HttpSendRequest(...) // takes ~200 ms
Why does the first HttpSendRequest(...) take so much longer? This is very consistent, regardless of the URLs.
Thanks,
Greg
-
October 11th, 2009, 05:12 PM
#2
Re: Why does first ever HttpSendRequest take longer?
Get a packet capture to determine if it really is a genuine network delay, the SYN packet doesn't actually get sent until HttpSendRequest() is called. I can't see any reason why your implementation\code would delay, so might be DNS\network.
-
October 12th, 2009, 02:26 AM
#3
Re: Why does first ever HttpSendRequest take longer?
It uses resolved ip directly instead of requesting it from DNS the second time you send the request. And for the very first time you send the request, the whole network path might needs some preparations for your existance.
Ah, and winhttp might use keep-alive connection (I've never used winhttp, so I don't know if it is default). In this case, the second request will be send without first connecting the server(already connected).
Last edited by DreamShore; October 12th, 2009 at 02:30 AM.
Nope
-
October 12th, 2009, 09:47 AM
#4
Re: Why does first ever HttpSendRequest take longer?
Thanks for the info. I forgot to mention that I'm using WinInet (not quite as good as WinHttp but needed for Windows Mobile). I thought about DNS resolution but am curious why I don't see the delay when sending to a second domain. It would have to resolve that as well. A co-worker guessed that it might be due to one-time overhead such as proxy detection and possibly initializing something for DNS resolution (i.e. maybe the DNS server itself is cached and available when sending to the second domain).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|