Security headers
Security headers. None of these is a ranking factor on its own, but HSTS is what makes HTTPS stick (no downgrade on the first visit), and the rest close the common holes that get a site injected with spam pages — which is a ranking disaster. Lighthouse's best-practices score and most security scanners check them, and a hosting review by a buyer or an ad network will too.
Key takeaways
- Check: Security headers is a site-level check in the technical group.
- Fix: X-Content-Type-Options: nosniff
- Not this: HSTS with preload before every subdomain serves HTTPS.
- Effort: 15 min, site-level check; the audit drafts the fix from your own page.
| Check | Security headers |
|---|---|
| Layer | site-level check |
| Group | Technical |
| Typical effort | 15 min |
| Weight in the score | 1 on a scale of 1 to 3 |
| Checked by | the website, the Chrome extension and the WordPress plugin (same analyser, 69 checks) |
How do you fix “Security headers”?
- Strict-Transport-Security: max-age=31536000 (add includeSubDomains only once every subdomain serves HTTPS, or those subdomains stop opening)
- X-Content-Type-Options: nosniff
- X-Frame-Options: SAMEORIGIN (or Content-Security-Policy: frame-ancestors 'self')
- Referrer-Policy: strict-origin-when-cross-origin
- Content-Security-Policy last, started as Content-Security-Policy-Report-Only; a strict CSP breaks inline scripts and ad tags if set blind.
- Where: .htaccess / nginx server block / Cloudflare Transform Rules / a security plugin's headers page.
What should you not do?
- A CSP copied from a tutorial that blocks your own analytics and ads.
- HSTS with preload before every subdomain serves HTTPS.
Example
# .htaccess Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" Header always set X-Content-Type-Options "nosniff" Header always set X-Frame-Options "SAMEORIGIN" Header always set Referrer-Policy "strict-origin-when-cross-origin"
Frequently asked questions
How long does it take to fix "Security headers"?
About 15 min. It usually needs a developer or the hosting panel.
Is "Security headers" checked per page or for the whole site?
It is a property of the whole site, so fixing it once covers every page. The website, the Chrome extension and the WordPress plugin run the same check.
What is the most common mistake with "Security headers"?
A CSP copied from a tutorial that blocks your own analytics and ads.
Sources
About the author
Related checks
Does your page pass this check? The audit runs all 69 and drafts the fix for you.