Sitewalk / Guides / Issue guides / Content-Security-Policy header

Content-Security-Policy header: how to check yours and add one safely

A Content-Security-Policy (CSP) is an HTTP header that tells the browser which scripts, styles and other resources a page may load. If someone gets bad code into your page, a good policy can stop the browser from running it. It is a security header, not a ranking factor, but it shows up in security and Lighthouse reviews, so clients ask about it.

Does your site send one?

Run this in a terminal:

curl -s -o /dev/null -D - https://yoursite.com/

Look for a line starting content-security-policy. No line means no policy. You can also open your browser's developer tools, go to Network, click the first request and read Response Headers.

Sitewalk checks only the home page response, and only whether the header is present, not whether its rules are good.

Why it matters

Without a policy the browser allows everything the page asks for. With one, you decide the sources. The risk of getting it wrong runs the other way: a policy that is too strict can break scripts, fonts and embeds.

How to add one without breaking the site

  1. Start in report-only mode. Send Content-Security-Policy-Report-Only first. The browser reports what it would block and blocks nothing.
  2. Read the reports, fix or allow the sources you trust, and repeat until the reports are clean.
  3. Switch to the enforcing header, Content-Security-Policy, with the same value.

A tiny first policy that blocks little and breaks nothing:

Content-Security-Policy: frame-ancestors 'self'; base-uri 'self'; object-src 'none'

That stops other sites framing your pages, stops <base> tampering and blocks old plugin embeds. Add script-src and style-src later, once the report-only data shows what you really load.

MDN notes two details worth knowing: if a directive has a nonce or a hash, the browser ignores 'unsafe-inline', and report-to replaces the older report-uri.

Where to set it: your server, your CDN's response header rules, your host's header settings, or a WordPress security plugin that has a headers screen. These lines were tested on nginx and Apache 2.4 on 16 Nov 2026 (Apache needs mod_headers on):

# nginx
add_header Content-Security-Policy-Report-Only "default-src 'self'" always;

# Apache
Header always set Content-Security-Policy-Report-Only "default-src 'self'"

Swap the header name for Content-Security-Policy when you switch to enforcing. In nginx, a location block that has its own add_header line drops every header set above it, so repeat the headers there.

Check it worked

Run the curl command again and look for the line. Load your key pages with the developer tools Console open: blocked resources are logged there. Then run an audit.

What Sitewalk found on real sites

Of 53 sites audited since the check went live on 4 Nov 2026, 31 (58.5%) sent no Content-Security-Policy header. By share of sites, that is the second most common header gap after clickjacking protection.

Our own site, sitewalkseo.com, sends the small policy above (checked 16 Nov 2026).

Check your whole site in one sentence

Sitewalk checks these headers along with 200+ other technical SEO checks. In ChatGPT, say:

Audit yoursite.com for technical SEO problems

Get started

Checked on 16 Nov 2026. Header behaviour from MDN Web Docs, read 16 Nov 2026. Sitewalk counts are from 87 audited sites, each site's latest audit: a small early-user group, a first look and not a survey.

More guides

All issue guides ยท All guides