What is HSTS? The header that keeps browsers on HTTPS
By TechCompare · Updated · How we check
HSTS makes browsers skip plain HTTP for your site. Send Strict-Transport-Security with a long max-age on HTTPS responses, and add includeSubDomains and preload only when every subdomain serves HTTPS.
HTTP Strict Transport Security (HSTS) is a response header that tells a browser to reach a site only over HTTPS for a set time. After the first visit, the browser turns every http:// link into https:// on its own and won't let visitors click past certificate errors. It closes the gap a plain redirect leaves, where the first request still goes out unencrypted.
How this is calculated
The header looks like Strict-Transport-Security: max-age=31536000. The max-age is in seconds, one year in this case, and every new HTTPS response starts the clock again. RFC 6797 tells browsers to ignore the header when it arrives over plain HTTP, since an attacker could add or strip it there. So HSTS only kicks in after the first secure visit.
includeSubDomains extends the rule to every subdomain. That's what you want for security, but it breaks any subdomain still on plain HTTP, like an old intranet page or a router's admin panel, for everyone who has visited the main site.
preload asks for the domain to be built into browsers through the list at hstspreload.org, which Chrome, Firefox, Safari and Edge all draw on. Then even the very first visit is protected. To get on the list, a domain has to redirect HTTP to HTTPS on the same host, serve every subdomain over HTTPS, and send a max-age of at least one year with includeSubDomains and preload. Getting off the list can take months, because it ships with browser updates.
Roll it out in steps. Start with a max-age of five minutes, then a week, then a month, checking that nothing breaks each time, and finish at a year or more. That's the ramp hstspreload.org itself suggests.
The SSL Checker reads the Strict-Transport-Security header from the site's HTTPS answer and shows what it says.
Verdict
Send HSTS with a max-age of at least a year on every HTTPS response once your redirects work. Check every subdomain before adding includeSubDomains. Only add preload when you're sure the whole domain will stay on HTTPS for years, because leaving the list is slow.
More SSL scenarios
Related guides
Frequently asked questions
Does HSTS replace the HTTP to HTTPS redirect?
How do I undo HSTS if something breaks?
Why does the checker show no HSTS on a site I know uses it?
Related tools
DNS Lookup
Look up a domain's DNS records on Cloudflare or compare several resolvers at once, and read its SPF, DMARC and DKIM records in plain words.
Use toolOpen Graph Visualizer
Preview how your website links will look when shared on Google, Twitter, Facebook, and Discord.
Use toolPassword Generator
Generate secure, random passwords locally in your browser.
Use tool