HSTS explained in plain terms means understanding a single header that turns a polite suggestion into a rule: once a browser has seen it, that browser will never again talk to your site over plain, unencrypted HTTP. The central question is why a redirect to HTTPS is not enough on its own, and the answer is that a redirect can be intercepted, while HSTS is remembered by the browser and enforced before any request leaves the machine.
Most sites already redirect HTTP visitors to HTTPS, and most site owners assume the job is done. It is not, because the redirect itself travels over plain HTTP, and an attacker sitting between the visitor and the site can intercept that first request, strip the redirect away, and serve the visitor a fake plain-text version of the site. The visitor sees a normal page, types a password, and never knows the connection was never secured.
HSTS closes that gap, and it costs almost nothing to switch on. This article explains what HSTS is, how it works, and why every serious website should have it, preferably with its name on the preload list.
Key takeaways
- HSTS is a header that forces browsers to use HTTPS for a site.
- It stops downgrade attacks that strip the redirect to HTTPS.
- It also blocks users from clicking through certificate warnings.
- It only protects after the first visit, unless the site is preloaded.
- The preload list, built into browsers, is the strongest form of it.
What HSTS is
HSTS stands for HTTP Strict Transport Security, and it is defined in RFC 6797, published in 2012. A server sends it as a response header, Strict-Transport-Security, with a max-age telling the browser how long to remember the rule, and from that moment the browser will convert every HTTP request for that site into HTTPS before sending it, and will refuse to connect if the secure connection cannot be established.
The header has three parts, and each one matters. The max-age, measured in seconds, sets how long the browser remembers, and the recommendation is at least a year, or 31,536,000 seconds.
The includeSubDomains flag extends the rule to every subdomain, so an attacker cannot dodge it by attacking a forgotten corner of the site. The preload flag is a request to be included in the list built into browsers, which is the only way to protect a first-time visitor.
The downgrade attack it stops is called SSL stripping, and it is older than HSTS itself. The attacker intercepts the victim’s first plain HTTP request, keeps an HTTPS connection open to the real site, and serves the victim a plain HTTP copy, reading and modifying everything in between. A redirect cannot stop it, because the attacker simply removes the redirect; HSTS stops it, because the browser never sends the plain request in the first place.
Certificate warnings get stricter too. Without HSTS, a browser that finds a certificate problem shows a warning the user can click through, and many users do, especially when they are in a hurry. With HSTS, the warning has no click-through, and the browser refuses the connection outright, which removes the human from a decision humans consistently get wrong.
Our guide to the TLS handshake explains the secure connection HSTS forces browsers to use, and our guide to DNS over TLS explains how the lookup that happens before the connection can be protected too.
How HSTS works
Everything starts with the first visit, and that is the weakness. On the first visit, the browser has never seen the header, so the first request goes out over plain HTTP, and an attacker who is already in position can intercept it. HSTS protects every visit after the first, which is a large improvement over nothing, but it leaves a gap that matters.
The preload list closes the gap. Browsers ship with a built-in list of sites that have asked to be preloaded, and a browser that has never visited your site still knows to use HTTPS, because the rule arrived with the browser itself. Getting on the list means submitting your domain, meeting strict requirements, and waiting for a browser release, and getting off it is deliberately slow, which is why the decision deserves care.
The requirements for preload are strict for a reason. The site must serve a valid certificate, redirect all HTTP traffic to HTTPS, set a max-age of at least a year, include the includeSubDomains flag, and include the preload flag. A site that fails any of these is rejected, because a preloaded site that later breaks HTTPS would lock its own visitors out with no quick fix.
Enforcement is entirely on the browser’s side. Once the rule is cached, the browser rewrites the address internally, changing http to https before any network traffic happens, and it applies the rule to every request, including images, scripts, and API calls. The server never sees the plain request, because it is never sent.
Expiry is the quiet risk. A max-age that is too short means the rule lapses during a holiday or a quiet period, and the next visit is unprotected again. The recommendation is a year or more, with the header sent on every response, so the clock keeps resetting and the protection never lapses while the site is in use.

Comparing HSTS with other transport protections
HSTS is one of several ways to push traffic onto secure connections, and each was built with a different emphasis. A plain redirect to HTTPS works until it is intercepted, a content security policy can upgrade insecure requests from inside a page, and certificate pinning ties a connection to one specific key, and each approach trades strength for scope in a different way.
The table below sets out the main contrasts between the leading approaches.
| Aspect | HSTS | Plain redirect | Certificate pinning |
|---|---|---|---|
| Stops SSL stripping | Yes, after first visit | No | Not its job |
| Protects first visit | Only if preloaded | No | Yes, pins ship with the app |
| Blocks warning click-through | Yes | No | No |
| Setup effort | One header | One redirect rule | Key management |
| Best for | Every website | Nothing on its own | Mobile apps |
The practical result is that HSTS is the right choice for every website, a plain redirect alone suits nothing on its own, and certificate pinning fits mobile apps with controlled servers.
Where HSTS is used
Every major website uses it. Search engines, banks, social networks, and government portals all send the header, and most of them are preloaded, which means the protection applies to first-time visitors as well as returning ones. It is one of the most widely deployed security headers on the web, and it costs nothing but a line of configuration.
Compliance frameworks expect it. Security audits and standards routinely check for HSTS, and its absence is flagged as a finding, which is why operations teams add it as part of routine hardening. It is a small control that auditors love, because it is easy to verify and hard to argue against.
Login and payment pages need it most. Any page that handles credentials or money is the prime target for a downgrade attack, and HSTS is the cheapest defence available. A site that handles passwords without HSTS is leaving its front door unlocked in the one place an attacker is most likely to try it.
Single-page applications depend on it silently. An app that loads its code over HTTPS and then calls an API must be sure every call is encrypted, and HSTS guarantees that even a mistyped address or a stale bookmark cannot downgrade a request to plain text.
Security scanners check for it automatically. Tools that grade a site’s headers report HSTS as a basic requirement, and a missing header is one of the most common findings in automated scans, which is why it is often the first header a team adds when they start taking transport security seriously.
Strengths and limits
The greatest strength of HSTS is its cost. One header, added to a server configuration, protects every visitor, blocks downgrade attacks, and removes the click-through that users abuse, and it does all of that without changing the site, the application, or the user experience. There are few security controls with a better return on effort.
It is also a strength that the preload list exists. A preloaded site is protected from the very first visit, which closes the one real gap in the design, and the list is maintained by the browser vendors, so a site owner only has to qualify once.
The limits are real, though. HSTS cannot protect a first visit without preload, it does nothing about mixed content inside a page, and a misconfigured header can lock a site into HTTPS before it is ready, which is why the rollout should be gradual, starting with a short max-age and lengthening it once everything works.
HSTS checklist
- Serve a valid certificate before enabling HSTS.
- Redirect all HTTP traffic to HTTPS first.
- Start with a short max-age, then raise it to a year.
- Add includeSubDomains only when every subdomain supports HTTPS.
- Apply for preload once the setup is stable.
- Send the header on every response, not just the homepage.
- Test subdomains before adding includeSubDomains.
- Keep HTTPS working during maintenance; HSTS does not forgive outages.
- Monitor the header in automated scans so it never silently disappears.
Frequently asked questions
What is HSTS in simple terms?
It is a header that tells a browser to use HTTPS for a site, always, and to refuse to connect if a secure connection cannot be made.
What is an SSL stripping attack?
It is an attack where a middleman intercepts a plain HTTP request, keeps a secure connection to the real site, and serves the victim a plain copy, reading everything in between.
Why is a redirect to HTTPS not enough?
Because the redirect itself travels over plain HTTP, and an attacker can intercept the first request and remove the redirect before the victim ever sees it.
What is the HSTS preload list?
It is a list of sites built into browsers, so the browser knows to use HTTPS even on the first visit, closing the gap that HSTS alone leaves open.
Can HSTS lock me out of my own site?
Yes, if HTTPS breaks while HSTS is active, browsers will refuse to connect, which is why rollout should be gradual and preload requires a stable setup.
When should I enable HSTS?
As soon as HTTPS works reliably across the whole site, starting with a short max-age, then lengthening it and applying for preload.
The bottom line
HSTS explained in one line is this: one header, remembered by the browser, that turns every future visit into a secure one and refuses to let anyone downgrade it.
It is the cheapest serious security control on the web, and the reason any site that handles logins or payments without it is taking a risk it does not need to take.
This article is general information about how HSTS works, not advice about choosing security settings for a particular system.







