What Is HSTS? Strict Transport Security Explained
What HSTS does that a redirect to https cannot: the first request, SSL stripping, max-age, includeSubDomains, preload, and when not to preload yet.

The short answer
HTTP Strict Transport Security (HSTS) is a response header that tells a browser: for the next stretch of time, only ever talk to this host over HTTPS. After a browser has seen it once, it rewrites every http:// address for that host to https:// before sending anything, and it refuses to let the visitor click past a certificate error.
It looks like this:
Strict-Transport-Security: max-age=31536000; includeSubDomainsThat one line closes a gap that a redirect from http to https leaves open, and it is the reason security scanners flag its absence. It is also one of the few headers that can lock visitors out of your own site if you send it carelessly, so it is worth understanding before you switch it on. You can see what any site currently sends with our free HSTS Checker.
Why a 301 to https is not enough
Most sites already redirect plain HTTP to HTTPS. Type shop.com into the address bar and the browser asks for http://shop.com, the server answers 301 Moved Permanently with a Location of https://shop.com/, and the browser follows. It feels secure, and once the padlock appears it is. The problem is the first hop.
The first request travels in the clear
That opening request, and the redirect that answers it, are plain HTTP. Anyone who can sit on the network path can read and change them: a café or hotel Wi-Fi, a compromised home router, a malicious hotspot with a familiar name. Your redirect only protects the visitor if it arrives untouched, and on a hostile network there is no promise that it will.
SSL stripping
In 2009 Moxie Marlinspike presented a tool called sslstrip that made this practical. The attacker does not break HTTPS at all. They answer the visitor over plain HTTP themselves, fetch the real HTTPS page in the background, and pass the content back with every https:// link rewritten to http://. The visitor sees the right site, minus the padlock, and most people never look for the padlock. Every password and form field then goes through the attacker in readable form.
The cookie leak
Even without an active attacker, the first plain request can give something away. A browser sends cookies with every request to the host they belong to. If a session cookie was set without the Secure attribute, the browser attaches it to that opening http:// request, in clear text, before your server has had the chance to redirect anything. A passive listener on the same network only has to read it. Marking cookies Secure fixes that half; HSTS fixes the request itself.
What browsers do with the header
HSTS changes the browser's behaviour, not the server's, which is why it can close a gap the server cannot.
The HSTS cache
When a browser receives the header over a valid HTTPS connection, it stores a rule for that host: force HTTPS until a point in the future, and optionally do the same for every subdomain. Chrome shows these rules on its internal page chrome://net-internals/#hsts, and our guide on how to test HSTS headers walks through reading them.
From then on, any request to http://shop.com, whether typed, bookmarked or linked from an old email, is upgraded inside the browser. Chrome even logs it as a 307 Internal Redirect with the reason HSTS. No plain HTTP leaves the device, so there is nothing to strip.
Two rules in the standard (RFC 6797) matter in practice:
- The header only counts over HTTPS. A browser must ignore
Strict-Transport-Securityon a plain HTTP response. Otherwise an attacker could inject a fake policy. Sending it on your port 80 site does nothing at all. - Each response refreshes the rule. Every HTTPS response carrying the header resets the clock, so a regular visitor never reaches the expiry.
The certificate error you cannot click through
Without HSTS, a certificate problem produces a warning page with an option to proceed anyway. With HSTS, that option disappears. The standard is explicit that the browser must give the user no way to continue. This is deliberate: an attacker presenting a forged certificate is exactly the case HSTS exists to stop. It also means an expired certificate on an HSTS host becomes a hard outage rather than a scary warning, which is one more reason to keep an eye on renewals with the SSL checker and our guide to checking an SSL certificate and fixing errors.
Anatomy of the header
The header has one required directive and two optional ones. Directive names are case-insensitive, which is why GitHub's includeSubdomains with a lower-case d works exactly like includeSubDomains.
max-age
The number of seconds the browser should keep the rule. Common values:
| max-age | Lasts | Typical use |
|---|---|---|
300 | 5 minutes | First test on a live site |
86400 | 1 day | Early rollout |
2592000 | 30 days | Late rollout |
31536000 | 365 days | Long-term setting and the preload minimum |
63072000 | 730 days | The example on hstspreload.org |
max-age=0 is special: it tells the browser to forget the rule. That is the only way to undo HSTS for people who have already visited, and it only reaches them when they come back.
includeSubDomains
Applies the rule to every name below the host that sent it. Sent from shop.com, it covers www.shop.com, app.shop.com, mail.shop.com and any internal name you have forgotten about. This is the directive that breaks things, because any subdomain that cannot serve valid HTTPS becomes unreachable in browsers that have seen the rule. Our post on common HSTS configuration mistakes covers the usual victims.
preload
Not part of the standard. It is a signal to the people who run the browser preload list that you consent to being built into the browser itself. On its own it does nothing.
Real headers from real sites
Here is what six well-known sites sent when we asked them on 28 October 2026. The differences are instructive.
- GitHub, Wikipedia and PayPal send all three directives and are preloaded.
- Facebook sends
preloadwithoutincludeSubDomains. Its domain is on the preload list, but the header as sent would not pass today's submission rules, which require both. - Mozilla sends a one-year policy for
www.mozilla.orgalone. - Google sends nothing on
www.google.comat all. That does not mean Google ignores HTTPS; it shows that the header is a per-host policy, and that whether you need it depends on your setup.
You can run the same comparison on your own domain with the HSTS Checker, or see HSTS in the context of every other header with the security headers checker.
The preload list
The weak spot that remains is the very first visit. A browser that has never seen your site has no rule, so that first request still goes out as plain HTTP. The preload list closes it. It is a list of domains compiled into Chrome, and Firefox, Safari and Edge use lists based on it. A preloaded domain is HTTPS-only from the moment the browser is installed.
How to get on it
Submissions go through hstspreload.org. Its requirements, as published today:
- Serve a valid certificate.
- Redirect from HTTP to HTTPS on the same host, if you listen on port 80.
- Serve all subdomains over HTTPS, including
wwwif a DNS record for it exists, and including internal subdomains that are not publicly reachable. - Serve an HSTS header on the base domain for HTTPS requests with
max-ageof at least31536000,includeSubDomainsandpreload. - If the HTTPS site on the base domain redirects (for example from
shop.comtowww.shop.com), that redirect itself must carry the header.
Point 5 catches a lot of sites. The apex usually does nothing but redirect, and teams often only configure headers on the host that serves pages. Check it with the redirect checker to see every hop, then with the HSTS Checker against the apex itself.
Once submitted, the site says new entries can take several months to reach the stable version of Chrome.
Getting off it is slow
Removal exists, but hstspreload.org warns that it may take 6 to 12 weeks to reach most Chrome users and longer for other browsers, with no guarantees beyond Chrome. During that time, any subdomain that cannot do HTTPS stays broken for everyone. The site's own advice to tool makers is blunt: preloading should be opt-in and never a default.
A useful perspective
Chrome and Safari now try HTTPS automatically for every navigation, whether or not a site uses HSTS. hstspreload.org itself notes that preloading only adds value when those automatic upgrades fail in the presence of an active attacker. For a typical business site, a correct HSTS header on every host is the big win. Preloading is the final increment, and only worth having once it is safe.
Who should not preload yet
Hold off on preload, and probably on includeSubDomains too, if any of these are true:
- A subdomain still serves plain HTTP. Webmail panels, old intranet tools, a printer or NAS with a friendly name, a hosting control panel, a status page on a provider that does not do HTTPS on custom domains.
- You do not have a full list of your subdomains. Export your DNS zone and read every record before deciding. Mail hosts are a frequent surprise; if you are already working through email records, our guide to setting up SPF, DKIM and DMARC is a good moment to take inventory.
- Customers get subdomains of your domain. A SaaS that gives each customer
customer.yourapp.com, some pointed at third-party services, cannot vouch for all of them. - You might move providers soon. A migration that briefly serves a hostname without a valid certificate becomes an outage rather than a warning.
- The domain is shared with another team whose hosts you do not control.
None of these stop you sending HSTS on the hosts you do control, without includeSubDomains. That still protects every returning visitor on those hosts.
How to turn it on safely
The short version, in order:
- Make sure every host you plan to cover serves a valid certificate and redirects http to https.
- Send the header on every HTTPS response from those hosts, starting at
max-age=300. - Raise it in steps, waiting out each stage: a day, a week, a month, then a year.
- Add
includeSubDomainsonly after you have checked every subdomain. - Consider
preloadlast, and only for a domain you expect to keep on HTTPS for good.
The server and CDN settings for Apache, Nginx, Caddy and Cloudflare, with the pitfalls of each, are in common HSTS configuration mistakes. Our security headers checklist covers how HSTS fits alongside the other headers a business site should send.
The takeaway
A redirect gets visitors to HTTPS; HSTS keeps them there, including on the networks where it matters most. Send it on every HTTPS response of every host, raise max-age gradually, treat includeSubDomains as a promise about every name under the domain, and only ask for preload when you can keep that promise indefinitely.
If you would rather have someone measure your current headers, fix them at the server or CDN and prove the result with the same checks, that is part of our website fixes work.
Tools mentioned in this post
- HSTS CheckerTest whether a site sends HSTS: the raw Strict-Transport-Security header, max-age in plain time, includeSubDomains, preload and the browser preload list.
- Security Headers CheckerScore any site’s security headers. HSTS, CSP, X-Frame-Options and more, with fixes.
- SSL CheckerCheck any site’s SSL certificate: validity, expiry date, issuer and chain.
- Redirect CheckerTest any URL’s redirects: every hop’s status code, Location and time, with loops and wasted hops called out.


