Vlad Aseyev
Vlad Aseyev

Reputation: 31

Clear DNS cache on iOS programmatically

I'm using NEDNSProxyProvider class for redirecting DNS traffic to my DNS server. Also I implemented feature for changing DNS server manually. My problem is handleNewFlow(_:) will not be called again if site was visited recently. So even if DNS server changed browser will get old IP. Is it possible to clear DNS cache on iOS or just some records?

Upvotes: 3

Views: 1628

Answers (1)

Imran
Imran

Reputation: 2543

The DNS cache doesn't ever flush, unless you make a DNS/networking related configuration change. DNS records have a Time To Live (TTL) value associated with them which tells a DNS cache how long the particular record is good for. Records in the cache are kept for their TTL, then re-queried.

While you get the DNS Response packet from DNS Server, in that response packet you can override the the TTL to your desire value.

Upvotes: 1

Related Questions