DNS 请求需要的带宽非常小，但是延迟却有点高，这点在手机网络上特别明显。预读取 DNS 能让延迟明显减少一些，例如用户点击链接时。在某些情况下，延迟能减少一秒钟。
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.
打开和关闭 DNS 预读取
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">
您可以通过将 content 的参数设置为“on”来改变设置。
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/">
Similarly, the link element can be used to resolve hostnames without providing a complete URL, by preceding the hostname with two slashes:
同样,link元素可以用来解析 hostnames 没有提供完整的URL的，但主机名前要有双斜杠:
<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.