This Cyber Monday Tuts+ courses will be reduced to just $3 (usually $15). Don't miss out.
There is little that is more frustrating than a webpage that takes a long time to load, or never loads at all.
It’s even more frustrating when you’ve got one of the latest, fast Macs that is connected to a superfast broadband (or normal broadband, for that matter) connection. You can be close to tearing your hair out wondering why webpages are slow to load. If this is your experience then this tutorial may have the answer.
Please Explain More
Safari, from version 5.0.1 onwards, employs a technique known as DNS prefetching. This is designed to ensure that webpages load faster. On occasion it can, unfortunately, have the opposite effect meaning that webpages can take a long time to load. Or simply not load at all.
The DNS Prefetching Problem
The problem of slow, or non-loading, webpages is often caused by DNS prefetching. First, let’s examine the DNS bit and then the prefetching aspect.
DNS is the Domain Name Server (or system) that associates IP (Internet Protocol) addresses with domain names.
IP addresses are strings of numbers such as 18.104.22.168. Entering that number into a web browser will take you to the BBC website, as would entering bbc.co.uk. Being human, we find the latter easier to remember.
The analogy that is often used is that DNS works like a telephone directory for the internet in that it translates names (domain names) into numbers (IP addresses).
Prefetching, in the context of DNS, is an attempt to resolve domain names before the web browser user attempts to follow a link.
The reason that this is done is that DNS resolution time – the time taken to look up and translate a domain name to an IP address (remember the phone directory analogy and how long it might take you to look up someone’s number) – can lead to a variable delays that contribute to user-percieved latency. That’s to say, how long you think the delay is in the webpage, from a new website, downloading.
There are two main solutions to the DNS prefetching problem. They are to first try an alternate DNS service. Using our telephone directory analogy, once more, it’s akin to using a Thomson Local, rather than Yellow Pages, to look up the required information.
The second is to disable DNS prefetching altogether.
Try a Different DNS Service
The purpose of trying a different DNS service is to rule out any issues with the DNS service used by your ISP (Internet Service Provider).
Two of the main DNS service providers are OpenDNS and Google DNS. Alternatively, you can search the internet for third party DNS services for more options.
You can change your DNS service settings either on each Mac that you own or, if you use all your Macs in one place such as a home or office network, you can update the DNS service settings on your router or Apple Time Capsule.
Disable DNS Prefetching
If the issue of slow, or non-loading, webpages persists, the next step is to disable DNS prefetching using a command in terminal.
Tip: Terminal is not for those who do not understand what they are doing. It is possible to compromise the smooth operation of OS X if you enter the wrong command. That said, you can copy the command from this article and paste it into terminal to ensure that it is entered correctly.
First, ensure that you have quit the Safari app. Then open up the Terminal app which is located in /Applications/Utilities.
When you see the command prompt, enter the following command. The command that you are entering will disable DNS prefetching.
defaults write com.apple.safari WebKitDNSPrefetchingEnabled -boolean false
Now relaunch Safari and test for the slow, or non-loading, webpage issue on any websites where you were having the problem.
Check Your Router
If disabling DNS Prefetching, with the terminal command, has solved your issue, then the root cause of the problem may lie with your router.
In order to determine if this is the case, check to see if your router’s manufacturer has issued a firmware upgrade in the time since you acquired your router. It may be that they have issued an upgrade that is intended to fix a number of issues and/or introduce new functionality to the device.
Visit the website for the manufacturer of your router to determine if firmware updates are available and, if they are, be sure to follow the installation instructions very carefully so as not to compromise the functionality of the router itself.
If your router is particularly old, it may be wise to upgrade to a more modern and robust device.
Having checked for the latest firmware on your existing router, or having replaced an old router with a new one, the next step would be to re-enable DNS prefetching.
How to Re-enable DNS Prefetching
Quit Safari and open the Terminal app, located in /Applications/Utilities.
When you see the command prompt, enter the following command. The command that you are entering will re-enable DNS prefetching.
defaults delete com.apple.safari WebKitDNSPrefetchingEnabled
Relaunch Safari and test by visiting any website with which you were previously experiencing problems with slow, or non-loading, webpages.
The Final Solution
After having upgraded your existing router’s firmware, or upgraded to a modern router, and re-enabling DNS prefetching you are still experiencing slow, or non-loading, webpages then the final solution would be to disable DNS prefetching once more.
Simply follow the earlier instruction for the Terminal command to disable DNS prefetching in Safari and leave it at that.
Having followed the instructions in this tutorial, you should now be viewing previously problematic websites without any slow, or non-loading, webpages.
If the solution for your was to disable DNS prefetching then your browser will not be looking up links to other websites before you click through to them. On occasion, and depending upon the DNS system, it may take a little while for the domain name to resolve to an IP address before the website loads in the browser.
Normally speaking, you will not notice any delay in domain name resolution except for in exceptional circumstances. Either way, the webpage performance should now have improved on the sites with which you were previously experiencing problems.