The six headers that matter
- Strict-Transport-Security (HSTS) tells browsers to use HTTPS only, so nobody on the network can downgrade a visit to HTTP. Use at least six months:
max-age=31536000; includeSubDomains. - Content-Security-Policy (CSP) lists where scripts, styles and frames may come from. It is the strongest defence against cross-site scripting, if it does not allow
'unsafe-inline'scripts. - X-Frame-Options or CSP
frame-ancestorsstops other sites from framing yours, which prevents clickjacking. - X-Content-Type-Options: nosniff stops browsers from guessing that an uploaded file is a script.
- Referrer-Policy controls how much of your URLs other sites receive;
strict-origin-when-cross-originis a good default. - Permissions-Policy turns off camera, microphone, location and other features for the page and its frames.
How the grade works
Each of the six headers scores a full point when set correctly, half a point when present but weak (a short HSTS, a CSP that still allows inline scripts, a referrer policy that leaks full URLs), and nothing when missing. Six points is an A; A+ also needs HSTS preload and no version numbers in Server or X-Powered-By. The checker also lists cookies without Secure, HttpOnly or SameSite.
The grade is a starting point, not a pen test: a perfect header set does not fix an injectable form, and a strict CSP needs testing so it does not break the site.
Rolling out CSP safely
Start with Content-Security-Policy-Report-Only and a report endpoint, watch what would be blocked for a week, then switch to enforcing. Replace inline scripts with nonces or hashes instead of allowing 'unsafe-inline'. Most frameworks (Next.js, Rails, Django) can add a nonce per request.
Set headers once at the edge (CDN, nginx, load balancer) so every response, including error pages and redirects, carries them. Then check again with this tool and the HTTP headers checker.