Before you go any further, this hack requires that you have SuperUser (su) access on your phone, a terminal emulator app, and the ability to type precise and case-sensitive instructions.
Next, this hack is very technical, though not particularly hard to do.
If you’re okay will all that, read on! If not, this is your chance to turn back.
How does it work?
Think of it this way, if you want to call someone on the telephone you can either memorize their phone number, or look their name up in a book (or your Contacts app) and find out their number. You can then dial their number on your phone and the other person’s phone will ring. Sounds simple enough, right?
Humans like words, computers like numbers. The words that you use to call up websites may be easy to remember for humans, but they’re not all that friendly for computers.
Domain names works the same way. You don’t know the IP address of pocketnow.com. What you don’t see happening is the DNS lookup. You type pocketnow.com into your web browser and tap go and your browser goes out and looks up the name in order to figure out the number (their IP address). This all happens behind the scenes, you don’t have to do anything to make it happen. But, just like looking up a name in a phone book, looking up the IP address takes time.
What does the hack actually do?
This hack speeds up your browsing experience in two ways:
1. By placing commonly used IP addresses in your Hosts table, you shortcut the need to do a DNS lookup for the websites you’re visiting, which can shave a several seconds off a page load (depending on the number of DNS requests and some other factors).
2. By placing the DNS names of the most frequently used ad servers in your Hosts table and telling them to resolve to 127.0.0.1 (your loop-back address) you can prevent those ads from loading, which means not only do you save on DNS lookup times, but also in ad serving and download time. (Before you flame me about this, read the rest of the article!)
Are they any down-sides?
In a word: yes.
Websites move IP addresses all the time (just like some people who change phone numbers all the time). If you’ve hard-coded their IP address into your Hosts table and they move, you’ll have problems until you find out their new IP address and update your Hosts table.
Websites can also have multiple addresses that represent servers scattered across the world (Google, for example). If you’re on the East coast of the United States you might get a Google server in New York. If you’re in Europe you might get a server in France. The closer a server is to you (theoretically) the faster it will be. If you hard-code the IP address, you may be missing out on this “content distribution network” (CDN) functionality, which could actually slow things down.
If you are using the Hosts table to block ads, some websites and apps may block you from being able to view their content. After all, most websites pay for their overhead, staff, bandwidth, etc. with revenues pulled in from advertisements. If you block their ads you block their revenue. If you block their revenue they have every right to block their content from being delivered to you. Even if they don’t block their content, I’d suggest that you pick out the top several sites that you visit, contact the person in charge, and tell him or her that you are blocking their ads via your Hosts table, and that you’d like to donate whatever amount you think is fair to offset their drop in ad revenue, which will probably be a couple bucks a month).
Additionally, many “free” apps are “paid for” by allowing ads to be displayed while you’re running them. These apps may stop working if you block their ads. In this case, uninstall the ad-based version of the app and purchase the ad-free version of the app (ask the developer to offer a paid, ad-free version if one is not already available).
Still want to try it?
First you’ll need to download a Hosts file, or create your own. If you want to use a Hosts file built just for this purpose, head over to this thread at XDA-Developers.com, download the .zip file, and extract the contents to the root of your sdcard.
Next, open your Terminal app (download one from the Market if you don’t have one already) and type the following (it is both case-sensitive, and spaces or lack thereof is important):
su (press enter; allow superuser permissions if prompted)
mount -o rw,remount t yaffs2 /dev/block/mtdblock3 /system (press enter; this sets the system folder as writable in preparation for the next step)
cp sdcard/hosts.for.mobile.txt /etc/hosts (press enter; this overwrites your existing Hosts table with the copy you downloaded)
mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system (press enter; this sets the system folder back to read only)
reboot (press enter; I’m not sure what this one does ;) )
When your Android finishes booting, open the web browser and surf to a site.
Does it work for you?
Let me know if you tried this hack and if you found it useful. Did it speed up pages? Did it slow them down? Did any websites stop working properly, which ones? Did any apps stop working, which ones?
Are you a webmaster? How do you feel about ad-blocking via Hosts? How would you react if someone told you they were blocking your ads, but wanted to make a monthly/yearly donation to you to offset the ad revenue?