Simple Firefox DNS Hacks To Boost Performance

By Angsuman Chakraborty, Gaea News Network
Friday, August 10, 2007

FirefoxWhile an individual DNS request often takes small time to execute, when the primary DNS server is overloaded or unavailable it can take quite sometime to resolve your requests. Now what has that to do with improving Firefox performance?

Firefox makes DNS requests to convert host name (like blog.taragana.com) to IP addresses (like 72.36.134.131), which is then used to fetch the web page. To reduce load on DNS servers and to speed up response time, Firefox caches DNS results. In Firefox, by default, the DNS requests are cached for only 1 minute. Firefox performance can be significantly improved by increasing the DNS cache time.

1. To do that type about:config in the address bar and press Enter.
2. Then right click on the preferences table and select New->Integer.
3. Type preference name as: Network.dnsCacheExpiration and Integer value as 3600.
4. This will increase the DNS expiration cache time to 1 hour. You may further increase it if you so wish.

There is a potential downside to increasing the cache time to very large values. Web service providers often use round-robin DNS to provide load balancing (and also increase reliability) with multiple servers on different IP addresses. Caching the DNS to very long period prevents them from providing you with valid website addresses when one or more of their server has gone down. It also prevents websites running on dynamic DNS services from giving you the latest IP addresses of such sites. However with a reasonable value of 1 hour you are fine.

However by itself it may not give you much benefit because by default Firefox can only cache 20 entires. So you should also increase the cache size to anywhere from 100 to 1000. I use 1000. You can change the cache size by similarly (see the documentation above for Network.dnsCacheExpiration) creating a new preference: network.dnsCacheEntries and set its value to 1000.

Close the browser and restart. You are done.

Discussion

shazam
January 19, 2010: 12:28 pm

Get openDNS if DNS for ip is slow

March 28, 2009: 10:59 pm

It seems that these 2 settings now default to more reasonable settings in FF3:
network.dnsCacheEntries - 512
network.dnsCacheExpiration - 3600

@Blowman. o.O that’s an awful shlep without any reasonable gain.

December 1, 2008: 7:41 am

@Blowman, @Dude
Guys,

I´ve developed a extension to make this job easier. Check at: https://addons.mozilla.org/en-US/firefox/addon/7408
You can change your host file, then refresh the DNS Cache of firefox without restart it;
Enjoy :)

September 24, 2008: 7:02 pm

^^^^^^^^^^^^^^^
why are you whining? your not supposed to be editing your hosts file constantly. if you want to do something like that then host a tiny dns server off your machine and use yourself as the dns host. it will cache all the ip to hostname data and all you do is a local query.

But you are correct, the hosts file is a pain to reload, but that’s why you aren’t supposed to rely on that. its being over used. plus having a lot of entries is more for your box to parse and go thru before making external queries.


Blowman
July 30, 2008: 3:39 pm

This “feature” has been driving me crazy.

I manually manage my hosts file to make sure that domain names resolve to the IP addresses I want. In other words, I don’t rely on DNS for all name resolution.

This “feature” of firefox means that after I edit my hosts file (which I do 2-3 times a day), I have to either restart FireFox or wait 60 seconds before the change will be reflected. What a pain.

April 29, 2008: 5:05 pm

thanks for the suggestion. My isp has awfully slow dns servers - and they are about 100 miles away to boot.

August 12, 2007: 5:50 am

Let me know how it goes.

August 10, 2007: 9:11 am

hi angsuman,

thanks for the tip.

My svchost has been getting bigger and bigger. I thought that was because of the increasing load that firefox was putting on it.

I will try and find if things improve !

BR,
~A

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :