4

In this link at the last it mentions

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

libcurl uses its DNS cache by default as long as you re-use the handle. You can change the time it'll hold entries in the cache - it is only meant to aid "spikes" or rapid requests to the same host names as it doesn't get the "true" TTL values.

I have gone through all the documentation of curl http://curl.haxx.se/docs/manpage.html but I could not find any way to change the time (TTL) curl hold entries in the cache.

How to set the curl cache item holding-time & how to clear the curl cache?

user3666197
  • 1
  • 6
  • 50
  • 92
user27111987
  • 995
  • 2
  • 10
  • 26

1 Answers1

3

See CURLOPT_DNS_CACHE_TIMEOUT:

Pass a long, this sets the timeout in seconds. Name resolves will be kept in memory and used for this number of seconds. Set to zero to completely disable caching, or set to -1 to make the cached entries remain forever. By default, libcurl caches this info for 60 seconds.

There is no explicit way to flush the dns cache other than closing the handle or possibly setting the timeout to 0 for the next request.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222