HSTS (HTTP Strict Transport Security, RFC 6797) is an HTTP response header that instructs browsers to only use HTTPS for future connections to the domain, for a specified duration. It closes the last window in which an attacker on-path can downgrade a user from HTTPS to plaintext HTTP.
Header Format
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
max-age— seconds the policy is remembered (63072000 = 2 years, the preload requirement)includeSubDomains— apply the policy to every subdomain toopreload— flag your intent for HSTS preload list inclusion
HSTS Preload
Chrome, Firefox, Safari, and Edge ship a hard-coded list of domains that are HTTPS-only from the very first request — no visit needed. Submit at hstspreload.org after publishing the header with preload.
Common Miss
- Publishing
includeSubDomainsbefore every subdomain has valid TLS (breaks the subdomains permanently for cached users) - Setting
max-age=0to disable — users who already cached the policy keep it until theirmax-ageruns out - Not aligning
max-ageacross CDN and origin
Use the security headers checker to validate your HSTS deployment.
Related
Check the CSP glossary entry, read what an SSL certificate is, and browse the full HTTP security headers explainer.