Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Headers
  5. X-DNS-Prefetch-Control

X-DNS-Prefetch-Control header

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

The HTTPX-DNS-Prefetch-Controlresponse header controls DNS prefetching, a feature by which browsers proactively perform domain name resolution on 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.

The intention is that prefetching is performed in the background so that theDNS resolution is complete by the time the referenced items are needed by the browser.This reduces latency when the user clicks a link, for example.

Header typeResponse header

Syntax

http
X-DNS-Prefetch-Control: onX-DNS-Prefetch-Control: off

Directives

on

Enables DNS prefetching. This is what browsers do if they support the feature when this header is not present.

off

Disables DNS prefetching. This is useful if you don't control the link on the pages or know that you don't want to leak information to these domains.

Description

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 can bereduced significantly at certain times, such as when the user clicks the link. In somecases, latency can be reduced by a second.

The implementation of this prefetching in some browsers allows domain name resolutionto occur in parallel with (instead of in serial with) the fetching of actual pagecontent. By doing this, the high-latency domain name resolution process doesn't causeany delay while fetching content.

Page load times – especially on mobile networks – can be measurably improved in thisway. If the domain names for images can be resolved in advance of the images beingrequested, pages that load many images can see an improvement of 5% or more in the timeof loading images.

Configuring prefetching in the browser

In general, you don't need to do anything to manage prefetching. However, the user maywish to disable prefetching. On Firefox, this can be done by setting thenetwork.dns.disablePrefetch preference totrue.

Also, by default, prefetching of embedded link hostnames is not performed on documentsloaded overHTTPS. On Firefox, this can be changed by setting thenetwork.dns.disablePrefetchFromHTTPS preference tofalse.

Examples

Turning on and off prefetching

You can either send theX-DNS-Prefetch-Control header server-side, or fromindividual documents, using thehttp-equiv attribute onthe<meta> element, like this:

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

You can reverse this setting by settingcontent to"on".

Forcing lookup of specific hostnames

You can force the lookup of specific hostnames without providing specific anchors usingthat hostname by using therel attribute on the<link> element with alink type ofdns-prefetch:

html
<link rel="dns-prefetch" href="https://www.mozilla.org" />

In this example, the domain namewww.mozilla.org will be pre-resolved.

Similarly, the link element can be used to resolve hostnames without providing acomplete URL, but only, by preceding the hostname with two slashes:

html
<link rel="dns-prefetch" href="//www.mozilla.org" />

Forced prefetching of hostnames might be useful, for example, on the homepage of a siteto force pre-resolution of domain names that are referenced frequently throughout thesite even though they are not used on the home page itself. This will improve theoverall performance of site even though the performance of the home page may not beaffected.

Specifications

Not part of any current specification.

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp