I've experimenting with configuring dnsmasq
on macOS for Apache vhosts instead of creating entries in /etc/resolver/<domain>
for each domain. In my case, I configured dnsmasq
to resolve .dev
to localhost
.
Since Safari had previously visited foo.dev
, it kept requesting that page, although dig
resolved foo.dev
to localhost
.
It didn't help to clear Safari's web cache and flush the system's DNS cache:
sudo dscacheutil -flushcache
It was first after a reboot that Safari properly visited the localhost
instance of foo.dev
(vhost).
So, is Safari mantaining its own DNS cache – and if so, how can it be flushed without restarting the system?
Best Answer
To clean DNS cache on macOS, the following command should be used. (commands used to clean caches seems to be different on different version of macOS)
Clean the DNS cache in Safari. Open Safari, Preferences -> Advanced. Check "Show develop menu in menu bar". Then go to menu bar, Develop -> Empty Caches. The shortcut is ⌥⌘E. (Restart of Safari may be needed)
References