In our study of 4,326 top websites , the average homepage sent 2.78 of the seven browser security headers, and 23% sent none. Most of the gap is not hard engineering. It's five to ten lines of config nobody got around to.
This post is the config. For each header: what it does, a safe starting value, and the one thing that can break.
1. Strict-Transport-Security (HSTS)
Tells the browser to use HTTPS for your domain for the next N seconds, even if someone types http:// .
Strict-Transport-Security: max-age = 31536000 ; includeSubDomains
Enter fullscreen mode
Exit fullscreen mode
Can break: any subdomain that still serves plain HTTP. Start with max-age=300 and no includeSubDomains if you're unsure, then raise it. Only add preload once you mean it: removal from the preload list takes months.
2. Content-Security-Policy (CSP)
Restricts where scripts, styles, images and frames may load from.…