Curl - How to set TTL for DNS cache and how to clear curl cache

This link last mentions

http://comments.gmane.org/gmane.comp.web.curl.library/40895

      

libcurl uses its DNS cache by default if you reuse the descriptor. You can change the time at which it will store entries in the cache - it is only intended to help "bursts" or fast queries for the same hostnames as non-"true" TTLs.

I went through all the curl documentation http://curl.haxx.se/docs/manpage.html but I couldn't find a way to change the time (TTL) of the curl cache entry.

How to set curl retention time and how to clear cache trap?

+3


source to share


1 answer


See CURLOPT_DNS_CACHE_TIMEOUT :

Skip long, this sets the timeout in seconds. Name resolution will be kept in memory and used for this number of seconds. Set the value to 0 to completely disable caching, or set to -1 to create cached entries permanently. By default libcurl caches this information for 60 seconds.



There is no explicit way to clear the dns cache other than closing the handle, or perhaps setting a timeout to 0 for the next request.

0


source







All Articles