cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: liburl dns cache?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 2 Apr 2002 15:18:35 +0200 (MET DST)

On Tue, 2 Apr 2002, Phillip Stevens wrote:

> I understand libcurl has a dns cache?

It does, yes.

> will the following below cause two DNS lookups? (PERL) I'm hoping it will
> only cause one lookup.

Without digging into code, the DNS cache is enabled by default and will cache
the result of name resolve calls for 60 seconds. You can change the timeout
using CURLOPT_DNS_CACHE_TIMEOUT.

The cache is stored on a per handle basis, unless you use the
CURLOPT_DNS_USE_GLOBAL_CACHE option.

I just now realized that these two aren't described in the man page and I've
added them just now, something like this:

     CURLOPT_DNS_CACHE_TIMEOUT
             Pass a long, this sets the timeout in seconds. Name
             resolves will be kept in memory for this number of
             seconds. Set to zero (0) to completely disable
             caching, or set to -1 to make the cached entries
             remain forever.

     CURLOPT_DNS_USE_GLOBAL_CACHE
             Pass a long. If the value is non-zero, it tells curl
             to use a global DNS cache that will survive between
             easy handles creations and deletions. This is not
             thread-safe and this will use a global varible.

> How big can the libcurl cache be? could it cache hundreds of domains before
> ending the session? (before running cleanup) -

Yes, it can. And yes it will.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-04-02