Windows will cache the DNS entries we have accessed for the next resolution of the domain name. We can add the validity period of the project's old control cache in the registry.
HKEY_CURRENT_USER/software/Microsoft/Windows/CurrentVersion/Internet Settings
Value Name:DnscachetimeoutData Type: REG_DWORD Radix: decimal value: (time in seconds)
Value Name:ServerinfotimeoutData Type: REG_DWORD Radix: decimal value: (time in seconds)
However, sometimes we cannot change the relevant settings on the user's machine at will, and we just need to immediately refresh the local DNS Cache under specific circumstances. After reading msdn, we did not find any relevant method. The Windows component ipconfig.exe provides a command line parameter for refreshing DNS, "ipconfig/flushdns". Therefore, it tracks ipconfig.exe to see how it uses flushdns. Finally, it is called.Dnsapi. dnsflushresolvercacheTo flushdns.