Controlling DNS prefetching

As of version 3.5, Firefox supports DNS prefetching. This is a feature by which Firefox proactively performs domain name resolution on both links that the user may choose to follow as well as URLs for items referenced by the document, including images, CSS, JavaScript, and so forth.

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.

Background

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 thenetwork.dns.disablePrefetch preference to true.

Also, by default, prefetching of embedded link hostnames is not performed on documents loaded over HTTPS.  This can be changed by setting thenetwork.dns.disablePrefetchFromHTTPS preference to false.

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 "off".

This can also be done from individual documents, using the http-equiv attribute on the <meta> element, like this:

<meta http-equiv="x-dns-prefetch-control" content="off">
 

You can reverse this setting by setting content to "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 dns-prefetch:

<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.

See also

Controlling DNS prefetching的更多相关文章

  1. seo网页加速技术,预加载 DNS Prefetching 详解

    seo网页加速技术,预加载 DNS Prefetching 详解 DNS Prefetching 是什么 : DNS 是什么-- Domain Name System,域名系统,作为域名和IP地址相互 ...

  2. DNS Prefetching

    For Developers‎ > ‎Design Documents‎ > ‎ DNS Prefetching 目录 1 Problem 2 Solution 3 Architectur ...

  3. [WebKit]浏览器的加载与页面性能优化

    非常棒.非常系统的一份资料,值得阅读! 原文来自百度泛用户体验. 作者:nwind 本文将探讨浏览器渲染的loading过程,主要有2个目的: 了解浏览器在loading过程中的实现细节,具体都做了什 ...

  4. MDN > Web technology for developers > HTTP

    The Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia ...

  5. HTML5 prefetch即预加载

    原文地址 声明:此文带着自己的理解,不完全按原文翻译 prefetch 即预加载,在用户需要前我们就将所需的资源加载完毕. 有了浏览器缓存,为何还需要预加载? 用户可能是第一次访问网站,此时还无缓存 ...

  6. 前端优化:DNS预解析提升页面速度

    在网页体验中我们常会遇到这种情况,即在调用百度联盟.谷歌联盟以及当前网页所在域名外的域名文件时会遇到请求延时非常严重的情况.那么有没有方法去解决这种请求严重延时的现象呢? 一般来说这种延时的原因不会是 ...

  7. 【转】浏览器DNS 预取读技术的危害

    今天中午在http://news.ycombinator.com/news看到一篇文章标题: Saved 10 billion DNS queries per month by disabling D ...

  8. DNS Prefetch初认识

    今天在看一个后台框架时,发现这样的代码: <link rel="dns-prefetch" href="//0.s3.envato.com">< ...

  9. DNS 预解析

    DNS 解析也是需要时间的,可以通过预解析的方式来预先获得域名所对应的 IP. <link rel="dns-prefetch" href="//yuchengka ...

随机推荐

  1. SPOJ - PGCD Primes in GCD Table(莫比乌斯反演)

    http://www.spoj.com/problems/PGCD/en/ 题意: 给出a,b区间,求该区间内满足gcd(x,y)=质数的个数. 思路: 设f(n)为 gcd(x,y)=p的个数,那么 ...

  2. fiddler抓包https

    http://blog.csdn.net/idlear/article/details/50999490 charles也能抓取https请求 http://blog.csdn.net/jiadoud ...

  3. 【Docker】Segmentation Fault or Critical Error encountered. Dumping core and abort

    背景 CentOS7 安装Docker后,load镜像时出现以下错误: Segmentation Fault or Critical Error encountered. Dumping core a ...

  4. windows 下搭建python虚拟环境

    ###################################windows 下测试环境 C:\Users\wongg\django-cmdb>cd ..\cmdb ##下载get-pi ...

  5. SpringBoot 使用 EhCache2.x 缓存(三十一)

    SpringBoot 使用 EhCache2.x 缓存入门很简单,废话少说上干货: 1.在POM.xml中增加jar包 <!--开启 cache 缓存--> <dependency& ...

  6. 018PHP基础知识——函数(一)

    <?php /** *函数:一部分可重复执行的代码段,多次执行一次编译 * 特点: * 1.减少程序运行的复杂性 * 2.提高程序的可靠性 * 3.提高软件的开发效率 * 4.提高程序的维护性 ...

  7. 通过命令启动一个activity(am pm 命令)

    一.am的含义是activityManager 主要作用是启动activity.service .broadcast    1.通过adb命令启动acitvity,首先需要设置activity 的 e ...

  8. 201621123010《Java程序设计》第8周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 2. 书面作业 1. ArrayList代码分析 1.1 解释ArrayList的contains源代码 答:如图,可见co ...

  9. REST风格

    1)Representational State Transfer,表述性状态转移,是一种软件架构风格 2)实现步骤 第一步:修改URL 例:http://localhost:8090/SMBMS_C ...

  10. Winform开发常用控件之DataGridView的简单数据绑定——自动绑定

    DataGridView控件可谓是Winform开发的重点控件,对于数据的呈现和操作非常方便,DataGridView可谓是既简单又复杂.简单在于其已经集成了很多方法,复杂在于可以使用其实现复杂的数据 ...