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. Android 各API版本代码常量

    Android开发中常常有版本比较这个功能,来做版本兼容或者,其他相关效果等   以下是Android 7.0版本下的源码:   public static class VERSION_CODES { ...

  2. CF 160D Edges in MST 最小生成树的性质,寻桥,缩点,批量处理 难度:3

    http://codeforces.com/problemset/problem/160/D 这道题要求哪条边存在于某个最小生成树中,哪条边不存在于最小生成树中,哪条边绝对存在于最小生成树中 明显桥边 ...

  3. Thinking in Java之衍生类和基础类的初始化顺序

    <Thinking in Java>书里的例子,我又稍微修改了下代码: class Real{ public Real(String index) { // TODO Auto-gener ...

  4. iOS笔记之网络

    用POST方式上传数据时,数组怎么处理? NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data ...

  5. Jenkins的2个问题

    最近CI服务器从老版本的hudson升级为jenkins,遇到了2个问题,记录一下: 1.升级为jenkins后,junit report里面显示的test case数量为原来的两倍,每个test c ...

  6. 1、lambda表达式

    lambda表达式中的类型是通过上下文推断出来的,类似String[] strArr = {"as","sd"};右边元素的子类型. 匿名内部类的情况:需要引用 ...

  7. 探究js正则匹配方法:match和exec

    match是字符串方法,写法为:str.match(reg) exec是正则表达式方法,写法为:reg.exec(str) match和exec在匹配成功时返回的都是数组,在没有匹配上时返回的都是nu ...

  8. mongodb配置数据库文件夹,创建服务

    配置步骤 1.新建data文件夹,并在data下创建db及log文件夹 2.在mongodb安装目录下新增mongod.cfg文件,配置如下 systemLog:    destination: fi ...

  9. Jenkins配置slave遇到“无法启动该应用程序”的问题

    飞测说:最近在负责持续集成相关的工作,我们用的是jenkins+svn+maven+sonar, 今天在用slave这块出现了一个问题,排查了好久才解决,踩过的坑,现在和大家一起看看,希望对大家有帮助 ...

  10. python中多线程

    多线程 什么是多线程 开启线程的两种方式 进程和线程的区别 Thread对象的其他属性和方法 守护线程 死锁现象与递归锁 信号量.Event定时器 线程Queue 进程池和线程池 什么是多线程 在传统 ...