DNS Prefetching


I was reading this article here:

“To speed up browsing, Google Chrome resolves domain names before the user navigates, typically while the user is viewing a web page.”

“DNS prefetching just resolves domain names before a user tries to navigate, so that there will be no effective user delay due to DNS resolution … Google Chrome automatically scans the content of each rendered page looking for links, extracting the domain name from each link, and resolving each domain to an IP address. All this work is done in parallel with the user’s reading of the page, hardly using any CPU power. When a user clicks on any of these pre-resolved names to visit a new domain, they will save an average of over 250ms in their navigation.”

So this article got me thinking and I have a few questions about DNS resolution:

#1 - Google Chrome looks like they look up domain names, translate them into IP addresses, and then save the results somewhere. This would mean that it would only have to be resolved once correct? So once you navigate to other webpages, the DNS resolution time would be just the time it takes to read the file and retrieving the saved entry.

#2 - Do other browsers do any sort of prefetching like this? Looking at webpagetest.org test results on repeat view, it looks like there can be significant time for DNS resolution even though the DNS was resolved on the first view. Any comments on this?

#3 - If IE does not save DNS lookups, is there anyway you can tell the browser to start resolving lookups for a particular page without downloading a resource? For instance, let’s say a user comes to my webpage. When they first get there, it would be nice to let the browser know what they need to resolve for the base document to work.

#4 - Do you think other browsers will catch on to this concept if they do not already?

Travis Walters


By default IE caches the DNS lookups for 30 minutes and firefox caches it for 2 minutes.

I think the dns prefetching you are talking about is implemented in Firefox also… but not in IE . For the browsers that do implement it, you can force them to lookup and cache any arbitrary hostname you wish… So if your site is directing users to another site, you could in theory make the browser prefetch all the required lookups before they click…

All browsers cache DNS results in RAM for a period of time and there are caches at both the OS level and upstream as well. For the in-RAM cache you won’t even see a DNS lookup time.

Yes, the browsers all pick up techniques from each other and keep implementing (and improving on) the features from the others though it’s really only the really recent browsers (IE8-9, Firefox 3.6, Chrome 5) where they started getting really fancy and pre-fetching all sorts of things from DNS to even javascript code.

WebPagetest does a few things to make the “repeat view” more like a user coming back later in a new browser session rather than immediately:

1 - WebPagetest closes the browser between the first view and repeat view so any in-memory caches are lost (browsers cache requests for a session as well so you’d see very different behavior regardless of expires headers if the browser isn’t closed).

2 - We disable the OS DNS cache so that lookups go to the first level cache (ISP) and are more representative of someone coming back later after the TTL has expired.

There was a thread on it a little while back - http://www.webpagetest.org/forums/showthread.php?tid=169

Does look like (at least at the time) that support for explicit prefetching was pretty much limited to Chrome.

Absolutely. They are all taking innovations from each other pretty aggressively at this point so it’s just a matter of what release will pick up the improvements (particularly the implicit/automatic ones) and how long it takes for that browser to get decent market share (that last bit is always a killer).

Jim Roskind, a former colleague of Pat and myself (Pat, do you remember him? :slight_smile: ) has been working on this for Google. And he has done a nice video on that, which you can see here:


Kind regards,

Very cool, thanks.

The newer generation of browsers do amazing things for performance - I can’t wait for them to build market share so we can stop focusing on helping out the older browsers. A good number of the techniques that people focus on won’t be as critical anymore because the browsers work around it (though they still don’t hurt).