The six security headers every website should send
HSTS, CSP, clickjacking protection, nosniff, Referrer-Policy and Permissions-Policy explained in plain English, with sensible starting values.
Published · updated
// short answer
Every website should send six security headers: Strict-Transport-Security (HSTS), Content-Security-Policy, clickjacking protection, X-Content-Type-Options, Referrer-Policy and Permissions-Policy. Most are one line each; CSP needs the most care.
Every time someone visits your website, your server sends back the page plus a short list of instructions called headers. Most visitors never see them. Browsers read them, though, and some of those instructions tell the browser how to protect the person using your site.
These are security headers. They cost nothing, they don't change how your site looks, and a developer can usually add them in an afternoon. Here are the six that matter most, what each one does in plain English, and a sensible starting value.
Why headers matter
A browser is cautious by default, but it also tries hard not to break old websites. That means some protections are switched off unless your site asks for them. Security headers are how you ask.
They don't fix bugs in your website. What they do is limit the damage if something goes wrong: a malicious script slips in through a plugin, another site tries to load yours inside a frame, or a visitor connects over a dodgy public Wi-Fi network. Think of them as seatbelts rather than brakes.
1. Strict-Transport-Security (HSTS)
What it does: tells the browser "only ever talk to this site over HTTPS, even if someone types or clicks an http:// link."
Without it, the very first request to your site might go out unencrypted before your server redirects it. On an untrusted network, that's a moment where someone could interfere. HSTS closes that gap for every later visit.
A sensible value:
Strict-Transport-Security: max-age=31536000; includeSubDomains
max-age is how long, in seconds, the browser should remember the rule (here, one year). Only add includeSubDomains if every subdomain you use already works over HTTPS.
2. Content-Security-Policy (CSP)
What it does: gives the browser a list of places your site is allowed to load scripts, styles, images and other content from. Anything else is blocked.
This is the most powerful header, and the most involved. If an attacker manages to inject a script into your page, for example through a vulnerable form or plugin, a good Content Security Policy can stop that script from running. That's the main defence against cross-site scripting.
A cautious way to start is with a policy that only reports problems, so nothing breaks while you learn what your site loads:
Content-Security-Policy-Report-Only: default-src 'self'; img-src 'self' data: https:; frame-ancestors 'none'
Once the reports look clean, switch to the enforcing Content-Security-Policy header. Be wary of 'unsafe-inline' for scripts: it switches off much of the protection.
3. Clickjacking protection: X-Frame-Options or frame-ancestors
What it does: stops other websites from loading your site inside an invisible frame.
Clickjacking is when a malicious page shows your site in a hidden frame and tricks visitors into clicking buttons they can't see, like "confirm" or "delete". The fix is to say your site may not be framed by others.
The modern way is the frame-ancestors part of your CSP. The older header, X-Frame-Options, still works everywhere and is worth sending too:
X-Frame-Options: DENY
Content-Security-Policy: frame-ancestors 'none'
Use SAMEORIGIN or 'self' instead if your own site needs to frame its own pages.
4. X-Content-Type-Options
What it does: tells the browser not to guess what type of file something is.
Some browsers used to "sniff" files and decide for themselves that, say, an uploaded text file was really a script. That guessing can be abused. X-Content-Type-Options has exactly one value, and it switches the guessing off:
X-Content-Type-Options: nosniff
This is the easiest header on the list. There's no reason not to send it.
5. Referrer-Policy
What it does: controls how much of your page address is shared with other sites when a visitor clicks a link away from you.
Page addresses sometimes contain more than you'd like: search terms, order numbers, or reset links. Referrer-Policy keeps that information on your site. A good default shares only your domain name with other sites and the full address with your own pages:
Referrer-Policy: strict-origin-when-cross-origin
Avoid unsafe-url and no-referrer-when-downgrade, which share more than most sites need.
6. Permissions-Policy
What it does: lists which powerful browser features your site is allowed to use, such as the camera, microphone or location.
Most business websites never need these. Turning them off means that if a third-party script on your page misbehaves, it can't quietly ask for them. Permissions-Policy is a simple "no thanks" list:
Permissions-Policy: camera=(), microphone=(), geolocation=()
Add a feature back only if your site genuinely uses it, like a store locator that needs location.
// free, passive, 30 seconds
See which security headers your site sends
A word on cookies
Headers aren't the only browser instructions that matter. If your site sets cookies, each one can carry flags such as Secure, HttpOnly and SameSite. These keep login and session cookies off unencrypted connections and out of reach of scripts. Our checker looks at the cookie flags on cookies your homepage sets, too.
How to add them
Where you add headers depends on how your site is hosted:
- WordPress: a reputable security or headers plugin can add most of them, or your host can add them at the server level.
- Managed hosting or a CDN: many hosts and CDNs have a "custom headers" or "response headers" setting in their dashboard.
- Your own server: they go in your Apache, Nginx or IIS configuration, or in your application code.
Add one header at a time and check your site still works after each change. CSP is the one most likely to need a few rounds of adjustment.
Check yours in seconds
Our free security headers checker makes one ordinary request to your homepage, just like a browser, and reads the headers that come back. It doesn't probe anything else. You'll see which of the six are present, which are missing, and what each gap means.
If you'd like to understand the wider picture first, read is my website secure? How to check in five minutes. If you'd rather someone else did the work, website security fixes from Odesstra are quoted per job, and we re-check after the change to confirm it's in place.