A few lines in every server response tell browsers to use HTTPS, not to guess file types and not to load your pages inside other sites. This guide shows which headers our own website sends, why, and how we introduced a content security policy step by step.
Instructions the browser follows on your behalf.
Security headers are part of the HTTP response, not of the page content. Visitors do not see them, but browsers apply them before showing anything. You can list them with curl -I followed by the address, or in the Network tab of the browser’s developer tools.
They do not replace updates, backups or strong passwords. They close a few common gaps that a website would otherwise leave open by default. They do not protect your email either: whether others can send messages in your domain’s name depends on DNS records, explained in our guide to SPF, DKIM and DMARC. The OWASP Secure Headers Project keeps an overview of the headers and their recommended values.
Five basic headers on every page.
Strict-Transport-Security
After the first HTTPS visit, the browser connects only over HTTPS for the stated period, even if someone types or follows an http:// address.
X-Content-Type-Options: nosniff
The browser uses the file type the server declares and does not guess, so a file declared as another type is not run as a script or opened as an HTML page. This does not replace checking uploads on the server.
X-Frame-Options: SAMEORIGIN
Other websites cannot show your pages inside a frame, which blocks tricks that hide your buttons under someone else’s page.
Referrer-Policy
With strict-origin-when-cross-origin, other sites learn only your domain when a visitor follows a link, not the full address of the page.
Permissions-Policy
The site does not use the camera, microphone, location, payments or USB, so the header switches those features off for every page.
Raise the period only when you are sure.
A browser remembers Strict-Transport-Security for the whole period you set. If HTTPS stops working during that time, visitors cannot fall back to HTTP. That is why we raised it in steps: one day first, then six months, then a year, each time after checking that the site and its certificate work.
-
includeSubDomainsapplies the rule to every subdomain. Add it only when every subdomain you own, now and later, works over HTTPS. Other projects run on subdomains of our domain, so we left it out. - The preload list builds HTTPS into browsers themselves. It requires
includeSubDomains, and removal takes a long time, so it is a decision for the whole domain, not for one website.
One place per header.
Our HTTPS, frame, file type and referrer headers come from the CDN in front of the server, so they also cover images, styles and scripts. The Permissions-Policy comes from the WordPress theme, because it only matters for pages.
Whichever place you choose, write it down and check that each header appears once. Two different values for the same header, one from the server and one from a plugin, make it hard to tell which one the browser follows.
Report first, enforce later.
A Content-Security-Policy lists the sources a page may load scripts, styles and images from. It is the strongest of these headers and also the easiest to get wrong: a missing source breaks a form or a menu without any warning to the site owner.
We started with the report-only variant, which shows in the browser what would be blocked without blocking anything. We listed our own sources, checked every type of page and switched to the enforcing header only when no page reported a problem. It is a sixth header on top of the five above and, like the Permissions-Policy, it comes from the theme.
For your own website.
- Does every page and every static file return the HTTPS header?
- Did you raise the HSTS period in steps, after checking that HTTPS works everywhere?
- Is includeSubDomains set only if every subdomain works over HTTPS?
- Do pages send nosniff, a frame rule and a referrer policy?
- Does Permissions-Policy switch off features the site does not use?
- Is it written down where each header is set, and does each appear once?
- Do responses avoid revealing server or CMS versions?
- Did you start a content security policy in report-only mode and check every page type?
Headers are one part of regular maintenance. Our WordPress maintenance checklist covers the checks before and after updates. The EU Web Index shows how often HSTS is missing on public and commercial websites across the EU.
Originally published on hiperlink.digital.


