Advertisement
OS X

How to Fix Slow and Non-Loading Webpages in Safari

by

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 Explained

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 212.58.244.69. 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 Explained

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.


The Solutions

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.

OpenDNS may prove more reliable than your ISP's DNS
OpenDNS may prove more reliable than your ISP's DNS

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.

Check your router, AirPort Extreme or TimeCapsule
Check your router, AirPort Extreme or TimeCapsule

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.


Conclusion

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.

Related Posts
  • Computer Skills
    Networking
    How to Change Your DNS for Safer, Faster BrowsingIntro to dns 400 v2
    When you open your web browser and type in hub.tutsplus.com to find something interesting to learn, your computer is able to find a server with the IP address 190.93.242.181. Among other technologies, a protocol called DNS helps your computer find that server. In this tutorial, I’ll show you what DNS is and some tips you can use to be safer on the web.Read More…
  • Computer Skills
    Hardware
    How to Check and Enable TRIM on a Mac SSDTrim preview retina
    You probably know that solid state drives (SSD) differ from Hard Disk Drives (HDD) in how they store information, and you may have heard that something called TRIM can maintain their performance. In this tutorial, I’ll not only show you how you can enable TRIM support for your SSDs, but also understand what the term means and how it fits into the functionality of solid state storage.Read More…
  • Computer Skills
    Electronics
    How to Install Alternative Web Browsers on the Raspberry PiPibrowser400
    If you are running the Raspian distro on your Raspberry Pi–and many people are–then the default web browser is probably your primary method for accessing webpages. In this tutorial, I’ll show you how you can optimise Midori and I’ll show you how to install some alternative web browsers and explain why you might want to use them.Read More…
  • Computer Skills
    Electronics
    Run the Ghost Blogging Software on a Raspberry PiGhostpi400
    In this tutorial I will show you how to host a blog on your Raspberry Pi using the Ghost blogging platform. Ghost is a brand new piece of blog software, currently under development which was recently funded by a Kickstarter campaign. Similar to the way Wordpress is distributed, you can opt to purchase a hosted blog or download the software to try out yourself. As Ghost is very new it is still quite simplistic, and this simplicity makes it ideal to run on a Raspberry Pi. You'll be able to write and edit posts and upload images to your blog. I'll also show you how to install google analytics so you can see how many people are reading your website.Read More…
  • Computer Skills
    Electronics
    Installing OpenWRT on a Raspberry Pi as a New Home FirewallRapi400
    OpenWRT is an active and vibrant home firewall project that was born on the Linksys WRT54G line of home routers. It has grown and expanded to support an amazing array of old and new hardware alike. The list of compatible hardware is large enough to require its own index. With the recent interest in the Raspberry Pi there is of course is an OpenWRT build for it as well. In this tutorial I will show you how to install OpenWRT on a Raspberry Pi, add a second network interface, and replace your home firewall with your new OpenWRT firewall.Read More…
  • Computer Skills
    Terminal
    40 Terminal Tips and Tricks You Never Thought You NeededIcon terminal 2x
    The Terminal is an exceptionally powerful tool, providing a command line interface to the underpinnings of OS X. It’s a topic we’ve covered at length before with our popular series Taming the Terminal. There’s a great deal that Terminal can do, from moving large numbers of files to changing preferences that we didn’t even know exist. To demonstrate just how versatile the Terminal is, I’ve rounded up 40 truly excellent Terminal tips and tricks that can come in very handy. Read More…