Prevent Chrome from caching a site's DNS records

后端 未结 3 2177
温柔的废话
温柔的废话 2021-02-20 17:42

Chrome caches DNS records and tends to ignore changes to the hosts file after it has successfully connected to my site (barring a restart). With DNS pre-fetching enabled, it is

3条回答
  •  臣服心动
    2021-02-20 18:06

    I'm not sure if this is exactly what you're looking for, but this annoys me too switching dev environments, and I stumbled across this internal chrome page that lets you clear the cache by the click of a button: chrome://net-internals/#dns. After going there click the Clear host cache button.

    Edit As noted in an answer below, the reason this doesn't immediately take effect is that you also need to flush the open sockets. After clearing DNS cache, also go to: chrome://net-internals/#sockets and click on the Flush socket pools buttons.

    Also keep in mind the operating system might do its own level of caching. Linux doesn't cache dns entries I think (at least for me clearing the chrome cache is good enough), but for windows or mac you might need to flush the OS-level DNS cache as well. Run ipconfig /flushdns from command line for windows or sudo dscacheutil -flushcache from command line for mac.

提交回复
热议问题