Archived Forum Post

Index of archived forum posts

Question:

DNS Caching?

Jul 04 '14 at 12:32

Got a question relating to the CKHTTP module for you.

We've had issues (formerly using Qt to do network requests) on computers with both IPv6 and IPv4 addresses, when we have a server on the IPv4 port. Qt's component takes over a second per request, presumably because it's trying to resolve the IPv6 address first. We found we could avoid this by replacing the domain name with a direct IP address (i.e. use "127.0.0.1" instead of "localhost" -- or similar for whatever domain name was used.)

With chilkat, this is already faster (presumably because set_PreferIpv6 already defaults to false), clocking in at around 168ms per request on a connection that has both IPv4 and IPv6 addresses (and we want IPv4). But this is still slower than the 48ms or so it takes for requests when we use a direct IP address instead.

Since we make many requests when our application first starts up, I was wondering if we could do this domain name -> IP address resolve just once, and then re-use that value for faster performance on all subsequent requests. Does Chilkat have something built in to allow this?


Answer

Chilkat will automatically cache (in-memory) DNS lookups so that only the 1st one results in an actual DNS query. Subsequent DNS name queries (for the same domain) will use the cache automatically. There are DnsCacheClear methods in a few Chilkat objects to clear the Chilkat-wide internal memory cache ( see the DnsCacheClear method in Chilkat.Socket here: http://www.chilkatsoft.com/refdoc/csSocketRef.html also see the same method in Chilkat.Http: http://www.chilkatsoft.com/refdoc/csHttpRef.html )