Guides · updated 23 Nov 2026
Website security headers explained
Six HTTP response headers a site can send to make browsers stricter: HSTS, Content-Security-Policy, X-Content-Type-Options, frame protection, Referrer-Policy and Permissions-Policy. What each one does and how to add them safely.
When a browser asks for a web page, the server sends back the page together with a set of headers: short lines of information about the response. Some of them are instructions to the browser to be stricter than it would otherwise be. The Security headers panel of a Domain Statistics report checks the home page for six of these and gives a score out of six. This guide explains what each one does.
Missing headers are very common, even on large sites, and a low score is not proof that a site is unsafe. They are an extra layer of defence: cheap to add, but each needs a little thought first.
Strict-Transport-Security (HSTS)
HSTS tells the browser to use only HTTPS for the site for a set time, given in seconds as max-age:
Strict-Transport-Security: max-age=31536000; includeSubDomains
Browsers ignore it if it arrives over plain HTTP. Once it is in force, visitors can't click past a certificate warning on the site (MDN). That is the point of it, but it also means an expired certificate becomes a hard failure, and OWASP warns that a misconfigured header can lock visitors out until max-age runs out. Our SSL/TLS certificates guide covers HSTS and the preload list in more detail.
Content-Security-Policy (CSP)
CSP lets a site say where the browser may load scripts, styles, images, fonts and other content from. MDN describes it as a defence that "helps guard against cross-site scripting attacks", where an attacker manages to get their own script into a page (MDN).
A policy is a list of directives. default-src is the fallback for any type of content not given its own rule, and script-src covers JavaScript:
Content-Security-Policy: default-src 'self'; img-src 'self' https:
Under a policy like this, inline scripts written directly in the page are blocked unless the policy allows them with 'unsafe-inline' or a similar exception. That's what makes CSP strong, and also what makes it the hardest of the six to add to an existing site: adverts, analytics, embedded videos and chat widgets all load from other places and each has to be allowed.
The safe way to start is the Content-Security-Policy-Report-Only header. The browser then reports what would have been blocked without blocking anything, so you can adjust the policy before switching it on.
X-Content-Type-Options
This header has only one value:
X-Content-Type-Options: nosniff
It tells the browser to trust the file type the server declares rather than guessing from the content. With it, a browser refuses a script or stylesheet sent with the wrong type, and won't treat, say, an uploaded text file as a web page (MDN). It rarely breaks anything, provided the server labels its files correctly.
Frame protection: X-Frame-Options or frame-ancestors
Clickjacking is a trick where another site loads your page invisibly inside a frame and lures visitors into clicking buttons on it. The defence is to tell browsers who may put your page in a frame. There are two ways, and the report counts either:
- The older
X-Frame-Optionsheader, withDENY(no framing at all) orSAMEORIGIN(only your own site). A third value,ALLOW-FROM, is obsolete: MDN says modern browsers that see it ignore the whole header (MDN). - The CSP directive
frame-ancestors, such asframe-ancestors 'self', or'none'to forbid framing entirely (MDN). It can list other sites that may frame yours. OWASP says it obsoletes X-Frame-Options in browsers that support it; MDN notes that X-Frame-Options also works in older browsers, so sending both does no harm.
Neither works as a <meta> tag in the page; both must be sent as real HTTP headers. And frame-ancestors doesn't fall back to default-src, so it has to be set on its own.
Referrer-Policy
When someone follows a link from your site, the browser can tell the destination which page they came from. Referrer-Policy controls how much of the address is passed on. That matters if your addresses can contain anything private, such as search terms or account details.
If a site sets nothing, today's browsers use strict-origin-when-cross-origin: the full address within your own site, only the domain to other HTTPS sites, and nothing to plain HTTP sites (MDN). OWASP still recommends sending it explicitly, with that same value, rather than relying on the default.
Permissions-Policy
Permissions-Policy switches off browser features a site doesn't use, both for the page and for anything embedded in it:
Permissions-Policy: geolocation=(), microphone=(), camera=()
The empty brackets mean "nobody". This limits what a compromised script or embedded advert could ask for. MDN marks the header as experimental and notes it doesn't work in some widely used browsers, so treat it as a useful extra rather than a guarantee (MDN). The report shows it as information only.
Headers you don't need, and ones to remove
- X-XSS-Protection is not one of the six. OWASP advises against using it, saying it can create cross-site scripting weaknesses in sites that would otherwise be safe. A good CSP does the job instead (OWASP cheat sheet).
- Server and X-Powered-By headers can announce the software and version a site runs. OWASP recommends removing
X-Powered-Byand makingServeruninformative. The report's Website panel shows the Server header when a site sends one.
Adding them to your own site
- Check your current headers with a Domain Statistics lookup, or in your browser's developer tools (Network tab, click the page, look at Response Headers).
- Start with the easy, low-risk ones:
X-Content-Type-Options, frame protection andReferrer-Policy. - Add HSTS once you're sure every part of the site, and every subdomain if you use
includeSubDomains, works over HTTPS. Start with a shortmax-ageand increase it. - Build a CSP in Report-Only mode first, then enforce it.
- Where to set them depends on your hosting: the web server configuration (Apache, nginx, IIS), a CDN such as Cloudflare, or a plugin in your content management system. Your host's documentation will say which applies.
Header details above are as described by MDN and OWASP, checked in November 2026. Browser support changes, so check the current documentation before relying on a particular header.
Sources
- developer.mozilla.org — Strict-Transport-Security: max-age in seconds, ignored over plain HTTP, users can't click past certificate errors
- developer.mozilla.org — Content-Security-Policy: controls which resources the browser may load for a page, helps guard against cross-site scripting; default-src as the fallback; inline scripts blocked unless 'unsafe-inline' is set; Content-Security-Policy-Report-Only for testing
- developer.mozilla.org — CSP frame-ancestors: which parents may embed a page; 'none' is similar to X-Frame-Options: deny; no fallback to default-src; not supported in a meta element
- developer.mozilla.org — X-Frame-Options: DENY and SAMEORIGIN; ALLOW-FROM is obsolete and makes modern browsers ignore the header; has no effect in a meta element
- developer.mozilla.org — X-Content-Type-Options: nosniff, the only value; blocks scripts and stylesheets served with the wrong MIME type and turns off MIME sniffing
- developer.mozilla.org — Referrer-Policy: the list of values; strict-origin-when-cross-origin is the default when no policy is set
- developer.mozilla.org — Permissions-Policy: allow or deny browser features such as geolocation and the microphone for a page and its iframes; marked experimental and not Baseline
- cheatsheetseries.owasp.org — OWASP HTTP Headers Cheat Sheet: don't use X-XSS-Protection; frame-ancestors obsoletes X-Frame-Options in supporting browsers; recommended Referrer-Policy strict-origin-when-cross-origin; remove X-Powered-By and non-informative Server values; HSTS can lock users out if misconfigured
Facts checked on 23 Nov 2026. Rules and figures change — check the source if it matters.