WebKitDNSPrefetchingEnabled not working?

8 July 2015, 12:14

A standard trick if Safari is slow for whatever reason is to issue the following command in a Terminal window:

defaults write com.apple.safari WebKitDNSPrefetchingEnabled -boolean false

This turns off Safari’s DNS prefetching, which is intended to speed things up but causes problems with some internet routers.

However, you might find it doesn’t stay activated (something you can check with defaults read com.apple.safari WebKitDNSPrefetchingEnabled — if the result is anything other than 0 (zero) then it’s deactivated itself). I played around and noticed that it kept turning itself off at random time intervals after being activated, and there didn’t seem to be any rhyme or reason to it.

Eventually I think I figured out the issue. If there are any entries in your /etc/hosts file then that might be causing the problem — for some bizarre reason.

The solution is to remove from /etc/hosts anything that shouldn’t be there by default. In short, /etc/hosts should look something like this:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost 

That’s it. Nothing below or above these lines.

,

---

Know better?

 
---