Re: DNS caching ?
Date: Wed, 28 Sep 2005 12:57:31 +0200 (CEST)
On Tue, 27 Sep 2005, Anindya Sinha wrote:
> Just wanted to check if libcurl supports DNS caching on an existing curl
That's exactly the kind of DNS caching libcurl supports!
> If I create a curl handle (via curl_easy_init ()) and use it to fetch from
> say, host.webserver.com. Say this has 2 DNS entries ip1 and ip2. I know curl
> does a DNS lookup and selects one of the 2 ip addresses and tries to fetch
> the content; if it fails, it tries the next ip address and so on till all ip
> addresses are tried.
Yes, but the whole name resolve chunk is kept in the DNS cache. Including all
the IP addresses.
> If the content is fetched successfully, does it cache this entry on that
> curl handle ?
It caches the DNS resolve after a successful lookup. The transfer mail fail
later on, but the entry may be cached anyway.
> if I were to request libcurl to fetch another document (after 1st
> successful fetch) from the same host.webserver.com, does it use the ip
> address it used before for the 1st fetch?
First it will attempt to re-use the previous connection.
Failing that, it will re-use the previously resolved address(es). In the same
order as before even (which has been debated before and should be fixed so
that the order is modified on repeated uses to better work with hosts
resolving to multiple IPs).
I hope this answers your questions. Ask more if not!
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2005-09-28