GUIDE

Security Headers Explained for Site Owners

Security headers are instructions your server sends to the browser before the page loads. They are not visible to visitors, they are not in the HTML, and almost every small business site is missing several of them. That is not paranoia: a missing header is how a page becomes clickjackable or how a harmless upload becomes a script.

This guide covers the five that matter for a normal brochure or shop site, what each one prevents, and what to write in your config.

HTTPS: the baseline

HTTPS encrypts the connection between the visitor and the server. Without it, anything typed into a form travels in the clear, Chrome labels the site "Not secure", and search engines treat it as a weaker result.

Certificates are free now. If your site is still on HTTP, that is a hosting decision nobody has revisited, not a cost problem. Fix the certificate, then redirect every HTTP request to HTTPS with a 301 so existing links keep working.

HSTS: closing the downgrade window

HTTPS alone has a weakness. A visitor typing your domain without a protocol makes a plain HTTP request first, and an attacker on the same network can answer it before the redirect happens. HSTS tells the browser "for this domain, never use HTTP again" for a set period.

The header: Strict-Transport-Security: max-age=31536000; includeSubDomains

That is one year. Add includeSubDomains only once every subdomain supports HTTPS, because it applies to all of them. Do not add preload unless you are certain, since removal from the preload list takes months.

X-Frame-Options: stopping clickjacking

Framing is when another site loads your page inside an invisible iframe and puts a fake button over the top. The visitor thinks they are clicking "claim your prize" and they are actually clicking "transfer" or "delete". It sounds exotic; it is one of the oldest tricks on the web.

The header: X-Frame-Options: DENY — or SAMEORIGIN if your own pages legitimately frame each other.

The modern equivalent is a CSP directive, frame-ancestors 'none', which does the same job and is supported everywhere that matters. Send either; sending both is fine.

X-Content-Type-Options: nosniff

Browsers used to guess a file's type from its contents. If a user uploaded a file that looked like a script, the browser would run it. nosniff tells the browser to trust the declared Content-Type and refuse to reinterpret.

The header: X-Content-Type-Options: nosniff

This one is free, has no downside, and takes effect immediately.

Content-Security-Policy: the powerful, fiddly one

CSP is a whitelist of where scripts, styles, images and frames may come from. Properly configured, it defuses most script injection, because an injected script from an unknown domain simply will not run.

It is also the header most likely to break a site, because a policy that forgets a font provider or an analytics domain will silently kill parts of the page. Start in report-only mode, watch what it would block, then enforce. A realistic starting policy for a static site is default-src 'self' plus the domains you actually use.

Referrer-Policy: what you leak

By default, a browser tells the destination site where the visitor came from. That is how analytics works, and it also means a URL containing a token could leak through an outbound link.

Referrer-Policy: strict-origin-when-cross-origin sends the full path for your own site and only the domain elsewhere. It is a sensible default and it does not break analytics in any way that matters.

Where to put them

No code is involved. Each line is a name and a value, and if you can edit one config file you can move a security score from 40 to 100 in an afternoon.

What headers cannot do

They do not patch your CMS, update a vulnerable plugin, or stop a weak password. A site can score 100 on headers and still be compromised through an outdated form plugin. Headers limit the blast radius of common classes of attack; they are not a substitute for maintenance.

Check yours

The security checker reads the headers your server actually sends and lists what is missing with the exact value to add. The full audit weights those results into an overall score alongside SEO, speed and accessibility.

A worked example

Take a typical small business site on shared hosting. A security check returns 40/100: HTTPS works, but there is no HSTS, no frame protection, no nosniff, and no CSP. The site is a brochure with a contact form.

Three headers fix almost all of it, and the config is four lines:

Score moves to 90. The remaining ten points are CSP, which is genuinely optional on a site that loads no third-party scripts of its own. That is the realistic shape of this job: fifteen minutes, no developer, most of the benefit.

Order of operations

  1. Confirm HTTPS works on every page and every subdomain.
  2. Redirect all HTTP to HTTPS with a 301.
  3. Add nosniff, frame protection and referrer policy. All are safe immediately.
  4. Add HSTS with a short max-age first, such as 300 seconds, then raise it once a week of normal traffic has passed without a problem.
  5. Add CSP last, in report-only mode, and only if you have your own scripts to protect.

How to verify

Run the security checker after each change. Headers are served per response, so one header block in the config applies to every page at once, which is why this is one of the few fixes that improves an entire site in a single edit.

What changes after the headers are in

Nothing visible. That is the point, and it is why this work gets postponed indefinitely. The change shows up in three quiet places: browsers stop being able to downgrade the first request, other sites cannot frame your pages, and a stray uploaded file cannot be reinterpreted as a script.

It also changes how your site behaves under a specific class of attack. Without frame protection, a competitor can overlay your checkout with their own button. Without nosniff, a misconfigured upload folder becomes an execution vector. Neither is exotic; both are prevented by one line each.

The maintenance side

Headers are set once and inherited by every page, which makes them unusually good value. The thing to remember is that a site rebuild can silently lose them: a new host, a new config file, or a platform migration resets the defaults. Add "run the security checker" to your post-launch checklist, alongside "run the link checker".

Common Mistakes to Avoid

Security headers are cheap to add and easy to get subtly wrong. These five mistakes appear on most sites that have tried:

Headers are configuration, so they are easy to change and easy to forget. Put them in the host config rather than individual pages, and they apply to everything forever.

What each header actually does

HeaderWhat it prevents
Strict-Transport-SecurityDowngrade to plain HTTP on the first request
Content-Security-PolicyInjected scripts and unexpected third-party loads
X-Frame-OptionsYour page being framed and used for clickjacking
X-Content-Type-OptionsA file being interpreted as a different type
Referrer-PolicyLeaking full URLs to third parties

Two hours of configuration closes five of the easiest attack paths on a small business site. Our security checker reports which of them your site sends today, and the guide to HTTPS and website security explains what each one protects against.

Frequently asked

Will adding headers break my site?

HSTS, nosniff and X-Frame-Options are safe defaults. CSP is the one that needs care, which is why you start in report-only mode.

Do I need all five?

HTTPS, nosniff and frame protection are table stakes. HSTS is strongly recommended once subdomains are secure. CSP is optional for a simple static site.

My host does not let me set headers

Ask support for HSTS and frame protection specifically. Most managed hosts will enable them, and some already do but do not document it.

Can security headers hurt my rankings?

No. They are invisible to ranking algorithms and occasionally help, since safe sites are less likely to be compromised and serve malware. The risk is only breaking your own functionality.

Do I need all of them?

No. HTTPS and HSTS are the floor. CSP, frame protection and nosniff are worth adding. Start with the cheapest and work down the list as you have time.

Run the checks yourself. The free audit scores your page on 24 tests and tells you what to fix: check any website. For one specific problem, the link checker, speed test, meta checker and security checker each go deeper on their own.

Written by Anthony Bailey · Anthony Bailey is a publisher, retired professor and computer technologist. He writes the guides on Website Checkmate and has spent his career explaining technical subjects to people who never signed up to be technical.