Clear WinInet DNS cache programmatically

The WinINet library caches the IP address for any URL accessible through it. Because of this, when the IP address for this URL changes, the WinInet library also HttpSendRequestswitches to the old IP address.

And, if the older IP is responding, then WinINet will send the entire HTTP request to the older IP address.

Is there a way to force a clear WinInet DNS cache?

or

Is there a way to force WinINet to send an HTTP request to the specified IP address (since we can get a newer IP address using gethostbyname())?

Note:

+3
source share
1 answer

You can try using flag when connecting:

INTERNET_FLAG_DONT_CACHE = 0x04000000 Does not add the returned object to the cache. This matches the preferred value, INTERNET_FLAG_NO_CACHE_WRITE.

Or you can take a look at DeleteUrlCacheEntry from WinInet documentation here

I want this to do the trick.

- UPDATE

From this document I saw that there is a better flag to use it, look at:

INTERNET_FLAG_PRAGMA_NOCACHE , - .

- UPDATE

@Pradeep, , : HKCU\Software\Microsoft\Windows\CurrentVersion\ \DnsCacheEnabled ServerInfoTimeOut DnsCacheTimeout 0.

+2

All Articles