X-Content-Type-Options header

The HTTP X-Content-Type-Options response header indicates that the MIME types advertised in the Content-Type headers should be respected and not changed. The header allows you to avoid MIME type sniffing by specifying that the MIME types are deliberately configured.

Site security testers usually expect this header to be set (and that the Content-Type header is correctly set for all resources).

The nosniff directive has two effects depending on the context:

Header typeResponse header
Forbidden response headerNo

Syntax

http
X-Content-Type-Options: nosniff

Directives

nosniff

Blocks a request if the request destination is of type style and the MIME type is not text/css, or of type script and the MIME type is not a JavaScript MIME type.

It also prevents MIME type sniffing for all other response types, causing the browser to use the declared Content-Type without examining the response content. In particular it prevents a browser from treating a response as text/html when it is loaded in a browsing context and the Content-Type header is absent or indicates a non-HTML type.

Specifications

See also