cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: DNS Cache

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 6 Aug 2008 12:58:41 +0200 (CEST)

On Wed, 6 Aug 2008, brubelsabs wrote:

> with LibCurl I want to check many URLs hence I do that in waves (consits
> only of different URLs) so no server will be overloaded. Each wave has its
> own multi-handle with its easy handles. At the end of each wave all handles
> are cleaned up.

The easiest way is probably to just re-use the multi handle all the time
instead of creating new ones all the time.

> How should I enable a DNS cache?

You mean if you want it to survive all the creating and deleting of handles?
You should use the share interface and add that share object to all easy
handles you want to use that same DNS cache.

> Does it suffice to set curl_easy_setopt(handle,
> CURLOPT_DNS_USE_GLOBAL_CACHE, 1);

The global cache is evil and shouldn't be used by any new applications at all.

> or do I have to use additionally a share handle?

If you insist on killing the multi handles all the time, then yes.

> What does the DNS cache do if it cannot resolve a domain name again and
> again? Does it remember that this domain is not resolveable?

No, it only stores successful resolves and never remembers any failures.

> Is there some way to look at the DNS cache, or some entry of it?

Not by the use of any public API, no.

-- 
  / daniel.haxx.se
Received on 2008-08-06