HSTS (HTTP Strict Transport Security) is a response header that tells the browser to use only HTTPS for a site, for a period the site sets. Once a browser has seen it, it turns every http:// link to that site into https:// before sending anything, and it no longer lets the visitor click past a certificate error.
How it works
The server sends the header on an HTTPS response:
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
max-ageis how long, in seconds, the browser remembers the rule. Each response that carries the header starts the period again.includeSubDomainsapplies the rule to every subdomain as well.preloadsays the domain asks to be on the preload list that browsers ship with.
Browsers ignore the header when it arrives over plain HTTP, so it only takes effect after a first successful HTTPS visit. That first visit, if it starts on http://, is still exposed. The preload list closes the gap: a domain on it is treated as HTTPS-only before the browser has ever visited it. The list, run at hstspreload.org, sets its own requirements, including a long minimum max-age and both includeSubDomains and preload.
Why it matters
Without HSTS, a visitor who types the bare domain or follows an old http:// link makes one unencrypted request first. On an untrusted network, such as public Wi-Fi, an attacker can intercept that request and keep the visitor on a plain HTTP or fake version of the site. HSTS removes that request for every visit after the first.
What can go wrong
includeSubDomainsgoes out while some subdomain (an old admin panel, an internal tool) still serves only HTTP, and browsers that saw the header can no longer reach it.- A long
max-agecannot be taken back quickly. Turning HSTS off means sendingmax-age=0over HTTPS, and it only reaches browsers when they visit again. - Preloading covers every subdomain, including internal ones, and hstspreload.org warns that removal from the list takes months to reach users.
- An expired or broken SSL certificate on an HSTS site leaves visitors no way to click through, so the site is simply unreachable until it is fixed.
Check it
The Security headers checker shows whether a URL sends Strict-Transport-Security, alongside the other security headers. It gives a one-time reading, so it is worth running again after a deploy or a server change.
Start monitoring today
Websites go down and code throws errors. Ranetrace tells you when it happens to yours, why it matters and what to do next.