HSTS Explained: How Strict Transport Security Protects Your Site
So what is HSTS? It is a response header (HTTP Strict Transport Security) that tells a browser to only ever talk to your site over HTTPS, never plain HTTP, even if someone types http:// or follows an old link. Once a browser has seen it, it refuses to load that site insecurely until the header's timer runs out.
That small instruction closes a real gap. Redirecting http:// to https:// helps, but the very first insecure request still leaves the device before the redirect happens, and that moment is exactly where a downgrade attack lives. HSTS removes the gap by making the browser upgrade to HTTPS itself, before any request is sent.
Below: the downgrade attack HSTS prevents, what the max-age value actually does, and the trade-off involved in joining the browser preload list.
The downgrade attack HSTS is designed to stop
Even when a site redirects all HTTP traffic to HTTPS, the browser's first contact is often plain HTTP. Someone sitting between the visitor and the site (shared Wi-Fi, a tampered router, a hostile network) can intercept that first insecure request and quietly keep the connection on HTTP, serving a modified version of your page. The visitor never reaches the secure redirect. This is the classic SSL stripping, or downgrade, attack.
HSTS defeats it by moving the decision into the browser. Once a browser has received a valid HSTS header from your domain, it rewrites every future http:// request for that domain to https:// internally, before anything is sent. There is no insecure first request left to intercept, so there is nothing to strip.
What the max-age value actually does
A typical header reads: Strict-Transport-Security: max-age=31536000; includeSubDomains. The max-age is a number of seconds telling the browser how long to remember the HTTPS-only rule. 31536000 seconds is one year, a common and sensible choice. Each time the browser visits and sees the header again, the clock resets, so an active site stays protected continuously.
- max-age: how long, in seconds, the browser enforces HTTPS-only for your domain. A real, non-zero value is what makes the header count.
- includeSubDomains: extends the rule to every subdomain. Only add it once every subdomain works on HTTPS, or you can lock yourself out of one.
- preload: a signal that you want to be added to the browsers' built-in list (see below). It does nothing on its own.
- max-age=0: switches HSTS off and tells browsers to forget the rule, used when you genuinely need to roll it back.
The preload list and its trade-off
HSTS has one residual gap: the very first time a browser ever visits your domain, before it has seen the header, it has no rule to follow. The preload list closes that gap. It is a list, built into Chrome, Firefox, Safari and others, of domains treated as HTTPS-only from the start, with no first visit needed.
The trade-off is commitment. Getting on the list usually means a long max-age, includeSubDomains and a preload directive, then submitting your domain. Removal is processed in browser release cycles, so undoing it can take weeks or months. If any part of your site, or any subdomain, ever needs to run over plain HTTP, preload will break it and you cannot quickly reverse that. It suits sites confident that everything they serve, now and later, will always be HTTPS.
Free, instant, no account
See your site's security grade in seconds.
Free, instant, and no account needed to see your grade.
Scan my site freePlain-English A to E grade in about 10 seconds. No account needed to see it.
How to add HSTS safely
The cautious path is to roll it out in stages rather than jumping straight to a year-long, preloaded header. A misconfigured subdomain or a forgotten HTTP service then surfaces while the rule is still short-lived and easy to undo.
- Confirm HTTPS works everywhere first, including every subdomain and any old service, before going near includeSubDomains.
- Start with a short max-age, for example a few minutes or hours, and watch for breakage.
- Raise it to a longer period such as one year once you are confident nothing is left on HTTP.
- Only consider includeSubDomains and preload when the HTTPS-only commitment is genuinely permanent.
- Add the header in your web server or hosting config (Apache, Nginx, or your host's control panel); on many WordPress hosts this is a one-line server rule rather than a plugin.
How EB Security checks your HSTS
Our free scanner reads the response headers your site already serves and reports whether HSTS is present with a real, non-zero max-age, rather than sent as an empty or zero value. It does this passively, from the outside, alongside related encryption checks such as whether http:// redirects to https://, whether the TLS certificate matches your domain and comes from a trusted authority, and whether outdated TLS 1.0 or 1.1 is still accepted.
HSTS is a hardening header, so a missing one nudges your grade rather than sinking it; a critical problem like no working HTTPS or an untrusted certificate is what caps a grade. The check tells you whether the header is there and configured sensibly. It is a read-only external scan: it cannot enter you onto the preload list or change your server, so treat the result as a fast, clear signal of what to fix, then apply the header yourself in your hosting config.
HSTS tells browsers to load your site over HTTPS only, closing the first-request gap that downgrade attacks exploit. Use a real max-age, add includeSubDomains and preload only once you are certain every part of your site will always be HTTPS, and roll it out in stages so a mistake stays easy to undo.