X-DNS-Prefetch-Control

Enabled Smaller but still important security response headers.


The X-DNS-Prefetch-Control HTTP response header controls DNS prefetching, a feature by which browsers proactively perform 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 have been resolved by the time the referenced items are needed. This reduces latency when the user clicks a link.

ℹ Read more about this header here.

Usage

This header is enabled by default but you can change its behavior like following.

export default defineNuxtConfig({  // Global  security: {    headers: {      xDNSPrefetchControl: <OPTIONS>,    },  },  // Per route  routeRules: {    '/custom-route': {      headers: {        'X-DNS-Prefetch-Control': <OPTIONS>      },    }  }})

You can also disable this header by xDNSPrefetchControl: false.

Default value

By default, Nuxt Security will set following value for this header.

X-DNS-Prefetch-Control: off

Available values

The xDNSPrefetchControl header can be configured with following values.

xDNSPrefetchControl: 'on' | 'off' | false;

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.