Speed up your browsing with help from your hosts file

Web pages these days are so full of advertisements, trackers, counters, hidden pixels, it’s a wonder they load at all. And who knows what information you’re revealing about your browsing habits.

Browser plugins like Adblock Plus and Ghostery can filter out a lot of the crud, but because these are scripts run in the browser itself, they can’t always stop the content actually being downloaded – they just hide or disable it once it’s arrived. So your web page will speed up but not by as much as is actually possible.

A better way to stop a lot of this unwanted material before it even reaches your computer is to get your operating system to block it for you.

This is done by editing (or replacing) a specific file on your computer, called “hosts“.

When your computer is asked to find a URL, whether it’s a web page, an image, a counter, or anything else, it first checks its hosts file to see if there is a particular entry telling it where to look, before it then hits the internet in order to find the object.

So it follows that if you don’t want to receive any advertisement images from (say) “adverts-r-us.com”, then if you add an entry to your hosts file saying that adverts-r-us.com is actually on your own computer, not on the web, when you computer loads a web page containing an ad on that domain, it will immediately fail to find the ad, so your browser will receive an error (which you’ll never see) and you won’t receive the ads. And this all happens in milliseconds because your computer isn’t even touching the web. Neat.

Of course, there are thousands if not millions of domains that serve up advertisements, counters, trackers, etc, and it would take a lifetime to find all of them and add them to your hosts file, by which time new ones would have sprung up. You’d never manage to block everything that is slowing down your browsing experience.

Guess what: someone has done it for you. At the someonewhocares.org website, an enterprising guy called Dan Pollock has posted a hosts file containing about 12,000 entries relating to domains that either serve you ads or track you in some way. So if you install it on your computer, your browser will be downloading much less unwanted material. This file is updated regularly, by the way.

Installation on a Mac

  1. Go to http://someonewhocares.org/hosts/ and you’ll see the contents of Dan’s hosts file. Drag your mouse from the first ‘#’ under the page title, right down to the bottom of the page (there will be a lot of scrolling so it will take a minute) and then copy it with CMD-C.
  2. Open your favourite text editor (I like TextWrangler though TextEdit should be fine), start a new document, paste what you just copied into the document, and save it on your desktop as a file called “hosts” (not “hosts.txt” or “hosts.doc”, just “hosts”).
  3. Now you have to put your new hosts file in the right place so your Mac will find it and use it. Open a Finder window and browse to the “etc” folder. It’s in the root folder of your boot drive. You may have to enable showing hidden files in order to see it.
  4. In that folder you’ll see there is already a file called “hosts”. No problem, rename it to “hosts.old”. You Mac will probably ask you for your password before renaming it for you.
  5. Now drag your new hosts file from your desktop into this folder. Again, your Mac will probably insist you enter your password before allowing the move.
  6. As a final step I restarted my Mac, to be sure that it would start using the new hosts file. I’m honestly not sure if you need to do this.
  7. Get ready for faster (and more private) browsing, especially on commercial sites with busy layouts and lots of advertising and trackers.

I’d recommend revisiting Dan’s site every few months and repeating the process, so that you pick up new trackers and domains that have been added.

Installation on Windows or Linux

If you read the hosts file on Dan’s website, you’ll see that in the initial comments block (all the lines starting with ‘#’), he’s given instructions for other platforms including Linux and various versions of Windows.

14 Comments

  1. but is it a good idea to tamper the host file cause the ip might change for some website right ?

  2. very useful article thanks for sharing

  3. WOW!Thanks for sharing your informative and amazing post, I hope everyone will be benefited if they read all of your post.

  4. Good article thanks for sharing

  5. Hi,

    Have you tried UC Browser? I used it once and it seems to be a little faster than other browsers and it has an inbuilt adblocker.

    And such browsers are eating away the revenue of bloggers.

    Regards,
    Ali

  6. It’s hard to come by well-informed people about this subject, however, you seem like you know what you’re talking about! Thanks

  7. Nice! Gonna give this a try now, thanks 🙂

  8. Adblock is good for users but what about the site owners. How would the survive without ads revenue. Now internet speed computers / mobile are fast enough and users should stop using apps and plugins like Adblock.

  9. Nice Post.. Thank you.. You are awesome..

  10. Thank you so much for sharing this amazing post.

  11. I don’t know how should I give you thanks! I am totally stunned by your article. You saved my time. Thanks a million for sharing this article.

  12. There are various ways to speed up the browsing, like cache saving method by chrome.

  13. Thanks for sharing great article

  14. Hi
    great post
    loved the writing style

Add a Comment

If you have used this form and would like a copy of the information held about you on this website, or would like the information deleted, please email info@zigpress.com.