# Security headers that improve both SEO and trust

Six response headers decide how a browser treats your pages: whether they always load over HTTPS, whether an injected script runs, whether another site can put you in a frame. No header is a ranking factor by name. Each one protects something your rankings and your visitors' trust rest on. This guide gives the values to set, what each does for search, and a way to audit yours in a minute.

Updated 2026-11-16 · Source: https://porteur.ai/guides/security-headers-seo

## What Google counts, and what it does not

Start with the facts. Google announced HTTPS as a ranking signal in August 2014 and called it "a very lightweight signal". Its page experience guidance still asks "Are your pages served in a secure fashion?", and adds that aspects beyond Core Web Vitals do not directly help a page rank higher. No header will move a page up on its own.

What headers do is protect the ground your rankings stand on. There are three routes from a header to your search traffic.

- **They keep HTTPS whole.** Google prefers the HTTPS version of a page as canonical unless it finds conflicting signals, and it names insecure dependencies and redirects through HTTP among them. HSTS and one CSP directive remove both.
- **They stop the injection that gets a site treated as hacked.** Google's spam policies class hacked content as spam, and a site that carries it can rank lower or leave the results. A Content-Security-Policy keeps an injected script from running.
- **They are read by the people and tools that decide whether to trust you.** Browsers, Lighthouse, a buyer's security team and automated scanners all read your headers before they read your copy.

## The six headers, and the value to start with

| Header | What it stops | Value to start with |
| --- | --- | --- |
| Strict-Transport-Security | A visit that starts over plain HTTP, where it can be intercepted | `max-age=31536000; includeSubDomains` |
| Content-Security-Policy | Injected scripts, mixed content, framing by other sites | Report-only first, then enforced |
| X-Frame-Options | Your page loaded inside someone else's, known as clickjacking | `DENY` or `SAMEORIGIN` |
| X-Content-Type-Options | A browser guessing that an uploaded file is a script | `nosniff` |
| Referrer-Policy | Full URLs, with their paths and parameters, sent to other sites | `strict-origin-when-cross-origin` |
| Permissions-Policy | Embedded scripts asking for the camera, microphone or location | `camera=(), microphone=(), geolocation=()` |

Two older headers no longer belong on the list. `X-XSS-Protection` drove a browser filter that current browsers have removed, so leave it out. And take away the headers that announce your software and its version, such as `X-Powered-By`: they help nobody except the person matching your stack to a known flaw.

## HSTS: the header Google names

A redirect from HTTP to HTTPS leaves one weak moment: the first request still travels in plain text, and anyone on the network path can answer it before your server does. Strict-Transport-Security closes that. Once a browser has seen the header, it goes straight to HTTPS for as long as `max-age` says, without asking.

For search, HSTS is the one security header Google's documentation mentions by name. Its page on canonical URLs lists three ways to make sure the HTTPS version is the one it indexes: a redirect from the HTTP page, a canonical link to the HTTPS page, and "Implement HSTS". Returning visitors also skip the redirect hop, because the browser rewrites the address itself.

```http
Strict-Transport-Security: max-age=31536000; includeSubDomains
```

Start with a short `max-age`, such as 300 seconds, check that every subdomain answers over HTTPS, then raise it to a year. The browser preload list asks for a year at least, `includeSubDomains` and the `preload` directive, and its own site warns that inclusion "cannot easily be undone".

> `includeSubDomains` covers every subdomain, including the staging server and the old blog nobody remembers. One of them without a valid certificate becomes unreachable for anyone whose browser has seen the header.

## Content-Security-Policy: what an injected script runs into

A Content-Security-Policy tells the browser which sources a page may load scripts, styles, frames and images from. A script injected through a comment field or a hacked database row is written inline or comes from a host that is not on the list, and the browser refuses to run it.

That is the injection Google's spam policies describe under hacked content: code added to existing pages, and redirects that send some visitors to another site. A policy does not close the hole the attacker used. It limits what the hole can do to your visitors while you find it.

Two directives matter for search directly. `upgrade-insecure-requests` makes the browser fetch every `http://` resource over HTTPS, which removes the insecure dependencies Google counts against the HTTPS version of a page. `frame-ancestors` says who may frame you, and replaces X-Frame-Options in current browsers.

```http
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' https://analytics.example; img-src 'self' data: https:; frame-ancestors 'none'
```

> A policy can hurt search when it ships without a test. Google renders pages with a current version of Chromium, so a policy that blocks the script rendering your content can leave Google with an empty page too. Send it as `Content-Security-Policy-Report-Only` first, read what would have been blocked in the browser console, then enforce. After that, run the live test in the URL Inspection tool and read the rendered HTML.

## The four smaller headers

- **X-Frame-Options** stops another site from loading your page in a frame and laying its own buttons over yours. Send `DENY` if nothing of yours is meant to be embedded, and keep it beside `frame-ancestors` for older browsers.
- **X-Content-Type-Options** with the value `nosniff` makes the browser trust the declared type of a file. Without it, a file uploaded as an image can be run as a script on your domain.
- **Referrer-Policy** decides what your pages tell the sites they link to. `strict-origin-when-cross-origin` sends your domain and holds the path back, so a reset link or an internal URL never lands in someone else's logs, and the sites you link to still see where the visit came from.
- **Permissions-Policy** switches off the browser features you do not use. A third-party script that turns hostile cannot ask your visitors for their camera or their location under your name.

## Where a visitor meets your headers

Nobody reads response headers before signing up. People meet their effects.

- Chrome has labelled every plain HTTP page "Not secure" in the address bar since version 68, in July 2018.
- In October 2025 Google announced that Chrome 154, due in October 2026, would ask for the user's permission before the first visit to any public site without HTTPS. A site where HTTPS is the only door never shows that prompt.
- A red Safe Browsing page appears when a site has been used to serve malware or phishing. The headers above make that harder to bring about.
- A company buying your product often runs a header check on your domain during its security review. A missing header becomes a question on a form before the contract is signed.
- Lighthouse reads the HSTS header in its Best Practices checks and flags one that is missing, shorter than a year, or lacking `includeSubDomains`.

## How to audit your headers in a minute

1. **Read them yourself** Run `curl -sI https://yourproduct.com` in a terminal, or open the Network tab of your browser's developer tools, click the first request and read the response headers. You are looking for the six names in the table above.
2. **Grade them** Paste the address into [Keybrum's free security headers checker](https://keybrum.com/tools/security-headers-checker). It loads the page like a browser, grades the headers from A+ to F, and gives the exact line to add for each missing or weak one, written for Next.js, Vercel, Netlify, Cloudflare Pages or nginx.
3. **Check more than the home page** Repeat on a deep page, an API route, a redirect, the 404 page and a static file. Headers set in the framework often miss what the CDN serves by itself.
4. **Look for the header that should not be there** While you are reading, check for `X-Robots-Tag: noindex`. Left over from a staging configuration, it takes pages out of Google without a word in the HTML.
5. **Audit again after each deploy** A framework upgrade, a new CDN rule or a change of host can drop a header without an error. Put the check beside your deploy, with the rest of your release checks.

## What headers do not cover

A full set of headers is one layer. It tells browsers how to behave on your pages. It says nothing about a database table anyone can read, an API route that skips the session check, or a secret key shipped in your JavaScript. A site can score A+ on headers and still hand its user table to a stranger.

Those holes are found by attacking the live app. [Keybrum](https://keybrum.com) sends 338 attacks at a deployed app and its backend settings, shows the proof for each one that worked, and attacks again after the fix until it fails. The header rules are part of that run, so the free tool and the paid attack agree. To see what a stranger's browser already receives from your app, paste the address into the [free check](https://keybrum.com/check): about ten seconds, no account.

For the configuration to paste on each host, a Content-Security-Policy written for Supabase, Stripe and analytics, and the traps that follow the obvious fix, read Keybrum's [guide to security headers](https://keybrum.com/guides/security-headers). The full attack is paid, [from €49 for a one-time report](https://keybrum.com/pricing).

## Questions

### Are security headers a Google ranking factor?

Not by name. The one confirmed signal in this area is HTTPS, which Google has described as lightweight since 2014. Headers matter to search through what they protect: an HTTPS version free of conflicting signals, and pages that carry only what you wrote.

### Does HSTS help SEO?

Google lists implementing HSTS among the ways to make sure the HTTPS version of a page is chosen as canonical. It also removes the redirect hop for returning visitors. It will not lift a page that ranks poorly for other reasons.

### Can a Content-Security-Policy hurt my rankings?

Only when it blocks something the page needs. Google renders with a current Chromium, so a policy that stops the script rendering your content can leave it with an empty page. Ship the policy in report-only mode first, then check the rendered HTML in the URL Inspection tool.

### Do I need X-Frame-Options if I already set frame-ancestors?

Current browsers follow the frame-ancestors directive and ignore X-Frame-Options when both are present. Sending both costs nothing and covers older browsers.

### Where do I set security headers?

Wherever your responses are built: the headers function in next.config.js for Next.js, vercel.json on Vercel, a _headers file on Netlify and Cloudflare Pages, add_header lines in nginx. Then check that static files and error pages carry them too.

### How often should I check my headers?

After every deploy that touches the framework, the CDN or the host, and once a quarter otherwise. Headers disappear silently, and nothing on the page tells you.

## Read next

- [Moving from HTTP to HTTPS: the checklist that keeps rankings](https://porteur.ai/guides/http-to-https-migration): Move from HTTP to HTTPS without losing rankings. Use one-hop 301s, update canonicals and sitemaps, fix mixed content, and verify the HTTPS property.
- [Web security and SEO: why a hacked site loses rankings](https://porteur.ai/guides/web-security-and-seo): A hacked site drops from search results within hours. Learn how security vulnerabilities damage SEO, what Google penalizes, and how to protect your rankings.
- [Why Google downgrades hacked sites, and how to prevent it](https://porteur.ai/guides/why-google-downgrades-hacked-sites): Google treats hacked content as spam: pages rank lower, leave the index or sit behind a warning. How the downgrade works, and the scans that prevent it.
- [Server response checker](https://porteur.ai/tools/server-response-checker): Paste a URL and time the server's answer: time to first byte, HTTP/2 or HTTP/3, brotli or gzip, Cache-Control, HSTS, the headers that decide when a page starts.
- [Technical SEO checklist for a small site](https://porteur.ai/guides/technical-seo-checklist): Run these 20 technical SEO checks, in order. Each shows how to check it free and what fixed looks like for a site under 1,000 pages.
- [Trust signals on a product site: what a stranger checks before paying](https://porteur.ai/guides/trust-signals-on-a-product-site): What a stranger checks in the first minute, the pages that answer each doubt, how to show proof without noise, and a checklist you can ship today.
- [HTTPS](https://porteur.ai/glossary/https): HTTPS is a small ranking signal. Serve every page over HTTPS, one‑hop redirect HTTP to HTTPS, fix mixed content, keep canonicals and sitemaps on HTTPS.

Paste your URL and the free check reads your pages the way a crawler meets them, with the searches and rivals around them, in about thirty seconds, and shows three findings whole. Free check: https://porteur.ai/
