What the headers do
- Strict-Transport-Security (HSTS): the browser only opens the site over HTTPS from now on, even if someone types
http://. - Content-Security-Policy (CSP): defines where scripts, images and fonts may be loaded from. The most effective protection against injected code.
- X-Frame-Options or
frame-ancestorsin the CSP: stops other sites from invisibly embedding your page (clickjacking). - X-Content-Type-Options: nosniff: the browser does not guess which file type is meant.
- Referrer-Policy: controls how much of the visited address is passed on to other sites.
- Permissions-Policy: switches off features like camera, microphone or location that the site does not need.
How the grade works
Each header present scores one point. Six points make an A, five a B, four a C, three a D, two an E and fewer an F. HSTS only counts over HTTPS. The grade rates whether the headers are set – not whether every value is ideal.
Setting headers
On Apache use Header always set in the .htaccess, on nginx add_header … always. Start a CSP in Content-Security-Policy-Report-Only mode so you see what it would block before it breaks anything.