3

I've noticed that significant amount of time is spent on initial domain DNS resolve and it works much faster after that. But hey.. 90% of websites have the same IP for many months!

Q: Is it possible to make some sort of local cache or at least to to make local cache lifetime longer?

Browsers: Firefox & Google Chrome

1
  • 1
    What OS? And what web browser? Some browsers keep their own caches - Firefox can be configured to increase the size and retention size of its cache from the about:config screen.
    – DMA57361
    Oct 16, 2010 at 16:04

3 Answers 3

2

It's fairly simple to set up a local DNS caching server. This does tend to reduce the latency when browsing the web a little. You don't even need to fiddle with IP validity durations (time-to-live): merely refreshing every few hours instead of several times per page visit is an improvement.

Under Debian, Ubuntu and derivatives, first install the resolvconf package. Resolvconf automatically handles all DNS source maintenance, so that whenever you connect to a network, the associated server is registered in /etc/resolv.conf (if you don't have a DNS caching server) or with your DNS caching server (if you have one).

Then, install a DNS caching server such as dnsmasq or pdnsd. Pdnsd is more advanced on the DNS caching front, as it can save its cache to disk whereas dnsmasq's cache doesn't survive across reboots. Pdnsd can also be configured to keep entries longer than they should be (which you do at your own risk).

2

For the enthusiast, you can set up your Ubuntu system as a local caching nameserver. This gives you the flexibility of setting your own expiry times, and it works across applications (not just in your Browser).

This caching nameserver guide will get you from start to finish, and it isn't very lengthy as you can see. It was updated for Ubuntu 8.04, but the steps are pretty much the same, even for the current Ubuntu release.

2
  • That guide is more complicated than it should be! I wouldn't recommend bind when smaller, simpler programs exist (see my answer); and installing the resolvconf package automates all the configuration (ditto). Oct 16, 2010 at 19:32
  • 1
    @Gilles it's not hard at all. You don't need to advertise your answer in my comments when it's a scroll away...
    – user1931
    Oct 16, 2010 at 20:01
1

I can't comment on configuring your OS, as I'm not a Linux user. But with Firefox, at least, load up about:config and look for the network.dnsCacheEntries and network.dnsCacheExpiration values.

network.dnsCacheEntries is a measure of how large Firefox's own cache will be, default is 20.

network.dnsCacheExpiration is the time-to-live of each cache entry, in seconds, default us 60.

According to the Mozilla KB neither of these values will appear by default, you'll have to add them manually if they don't exist.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .