This prefetching is performed in the background, so that the DNS is likely to already have been resolved by the time the referenced items are actually needed. This reduces latency when, for example, the user actually clicks a link.
DNS requests are very small in terms of bandwidth, but latency can be quite high, especially on mobile networks. By speculatively prefetching DNS results, latency when, for example, the user clicks a link can be reduced significantly (on the order of a second, in some cases).
The implementation of this prefetching in Firefox allows domain name resolution to occur in parallel with (instead of in serial with) the fetching of actual page content. By doing this, the high latency domain name resolution process doesn't cause delays during the process of fetching content.
Page load times -- especially on mobile networks -- can be measurably improved this way. If the domain names for images can be resolved in advance of the images being requested, pages that load a number of images can see a load time improvement of 5% or more.
Configuring prefetching in the browser
In general, you don't need to do anything to manage prefetching. However, the user may wish to disable prefetching. This can be done by setting the
network.dns.disablePrefetch preference to
Also, by default, prefetching of embedded link hostnames is not performed on documents loaded over HTTPS. This can be changed by setting the
network.dns.disablePrefetchFromHTTPS preference to
Controlling prefetching from content
Content providers have some control over the prefetching process as well. This is compatible with how Google Chrome handles DNS prefetching control.
Turning on and off prefetching
First of all, a server can opt out of DNS prefetching by serving content with the
x-dns-prefetch-control: HTTP header set to "
<meta http-equiv="x-dns-prefetch-control" content="off">
You can reverse this setting by setting
content to "
Forcing lookup of specific hostnames
The content provider can force the lookup of specific hostnames without providing specific anchors using that hostname by using the
rel attribute on the
<link> element with a link type of
<link rel="dns-prefetch" href="http://www.spreadfirefox.com/">
In this example, Firefox will pre-resolve the domain name "www.spreadfirefox.com".
Similarly, the link element can be used to resolve hostnames without providing a complete URL, by preceding the hostname with two slashes:
<link rel="dns-prefetch" href="//www.spreadfirefox.com">
Forced prefetching of hostnames might be useful, for example, on the home page of a site to force pre-resolution of domain names that are referenced frequently throughout the site even though they're not used on the home page itself. This will improve overall site performance even though the performance of the home page may not be affected.