Security Headers Beyond CSP: HSTS, Referrer-Policy and Permissions-Policy
Short answer: Four response headers add useful protection to a small business site with little risk: Strict-Transport-Security tells browsers to use HTTPS, Referrer-Policy limits how much address information leaves your site, Permissions-Policy turns off browser features you never use, and X-Content-Type-Options stops browsers guessing file types. Add them at the server or the CDN, start HSTS with a short lifetime, and check the result in your browser's network panel and a header scanner. Content Security Policy is separate and needs its own testing.
A copy-ready header block
These values suit a brochure site or a small shop that loads its own scripts and images. Adjust the Permissions-Policy list to match features you actually use.
Strict-Transport-Security: max-age=300
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=()
X-Content-Type-Options: nosniff
The HSTS value of 300 seconds, about five minutes, is deliberately short while you test. Once every page and every subdomain works on HTTPS, raise it to a longer period such as one year, which is 31536000 seconds. Do not add the includeSubDomains or preload options until you have checked each subdomain, because a forgotten test server on HTTP would become unreachable for returning visitors.
What each header does
Strict-Transport-Security (HSTS) tells a browser that has visited your site to use HTTPS for every request during the period you set. It blocks downgrade attacks on public Wi-Fi, where someone could otherwise strip the secure connection. It only has effect after a successful HTTPS visit, so it protects returning visitors most.
Referrer-Policy controls the address a browser sends in the referrer field when a visitor follows a link from your site to another site. The value strict-origin-when-cross-origin sends only the domain when the destination is another site, and sends the full address within your own site. This keeps internal paths, such as a customer account URL with a token in it, from leaking.
Permissions-Policy lets you switch off browser features such as the camera, microphone and location for your pages and any embedded frames. A shop that never asks for a location should say so, which also prevents a compromised third-party script from requesting it.
X-Content-Type-Options: nosniff tells the browser to trust the content type you declare. Without it, a browser may guess that an uploaded file is a script and run it. It is a single line with almost no side effects.
Set the headers on common hosts
The place you add headers depends on how your site is served:
- Nginx: add
add_headerlines inside the server block, using thealwaysparameter so the headers also appear on error pages. - Apache: use
Header always setin the virtual host or the.htaccessfile, after enabling the headers module through your host. - Netlify: create a
_headersfile in the publish folder with a path of/*and the header lines beneath it. - Cloudflare: create a response header transform rule that applies to all paths. This works even when your origin server is shared hosting.
After any change, clear the cache at the CDN layer as well, or the old response may keep being served for a while.
Test the headers
Open your site in a browser, open the developer tools, and load a page with the Network tab open. Click the main document request and look at the response headers. Check every page type, including a checkout page, because some hosts add headers only to the homepage.
Then run the address through a header scanner such as securityheaders.com. It grades your site and lists missing headers. Treat the grade as a checklist, not a target. A high grade with a broken form is worse than a middling grade with a working site.
Common problems
A header can break a page when it is too strict. Referrer-Policy set to no-referrer can stop analytics and some payment redirects from working correctly. A Permissions-Policy that blocks a feature a third-party widget needs, such as a video player's fullscreen request, will show a console error and disable the feature. Read the console after each change. If you use a page builder that injects scripts, check the builder's documentation before adding restrictive policies.
Keep the headers through every deploy
Headers set in a server file survive a redeploy only if that file is part of what you deploy. Many owners discover that a new theme, a staging copy or a container rebuild quietly drops the headers they added by hand in the control panel. After each release, repeat the check on at least three pages: the home page, a page with a form and a page that loads a third-party widget. Keep the header block in version control next to the site code, so a colleague can see what should be there and restore it.
If you use a CDN and a separate origin, check both. A header added at the edge can be overridden by one the origin sends, and the browser will show whichever arrives last in the chain. Your scanner result is the only single view that shows what a visitor really receives, so run it after every change to the hosting setup.
Roll out in order
- Add X-Content-Type-Options and Referrer-Policy first, since they rarely cause trouble.
- Add Permissions-Policy after you list every feature your pages use.
- Add HSTS with a short lifetime, and watch for a week.
- Raise the HSTS lifetime and consider subdomains only after everything serves HTTPS.
FAQ
Do these headers replace a Content Security Policy?
No. A Content Security Policy controls which scripts and resources can load, and it needs a longer test. The four headers here are simpler and separate.
How do I know if HSTS is working?
Check the response header in the browser, then confirm that a plain HTTP address redirects to HTTPS. Browsers store the setting for the lifetime you chose, so test with a fresh profile too.
Will these headers improve my search ranking?
Search engines do not treat these headers as a direct ranking factor that most owners can count on. Their value is protecting visitors and customer data.
Can my host add these headers for me?
Some hosts do. Check the control panel for a security or headers option before you edit configuration files yourself.
If you would like us to add and test these headers on your site, send us your hosting setup and our studio will reply with the exact changes for your platform.