zoukankan      html  css  js  c++  java
  • Controlling DNS prefetching

    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

  • 相关阅读:
    Java中的阻塞队列
    大数据笔记
    物联网小笔记
    shell 笔记
    Redis笔记
    rabbitMQ笔记
    java.lang.NoClassDefFoundError: freemarker/template/Template
    分布式系列学习-事务处理
    免费无需破解xshell xftp下载
    idea maven模块变灰或者java文件夹非 Sources文件夹
  • 原文地址:https://www.cnblogs.com/ymy124/p/4476997.html
Copyright © 2011-2022 走看看