How HSTS works
Even on a fully secure site, the first request a browser makes can still be a plain one. Someone types the domain without a protocol, the browser tries the open version, and your server redirects it. That first exchange happens in the clear, and it is the moment an attacker on the same network can intercept and hold the visitor on a plain connection.
HSTS closes that gap. It is a response header — Strict-Transport-Security — that your server sends over an encrypted connection, and it tells the browser to use HTTPS for this hostname from now on. The browser remembers, and on every later visit it rewrites the address internally before making any request. Nothing goes out in plain text and the redirect hop disappears.
The header carries a maximum age in seconds, saying how long the instruction lasts, and it is refreshed on each visit. It can add an instruction to apply to every subdomain, and a request to be added to the preload list that browsers ship built in, which protects even a visitor who has never been to your site before.
Why HSTS matters
It removes a category of attack that a certificate alone does not. Without it, a visitor on a shared or hostile network can be quietly kept on the plain version of your site and shown something that is not yours. With it, the browser will not make that connection at all, and shows an error the visitor cannot click past instead.
There is a smaller, everyday benefit too. Skipping the plain request removes a round trip on the first visit, which is worth something on a slow mobile connection. HSTS is not itself a ranking factor, and no search engine rewards it directly.
Where HSTS goes wrong
Almost every problem is the same problem: it was switched on too confidently. The instruction is stored in the visitor’s browser, not on your server, so you cannot withdraw it from someone who has already received it. If your certificate lapses, or a subdomain has none, those visitors cannot reach the site and turning HTTPS back off does not help them — their browser refuses to try.
The subdomain instruction causes most of the accidents. It applies to every host beneath the domain, including a staging server, an old mail interface or a legacy system nobody remembered, any of which may have no certificate at all. Preloading is the other trap: getting onto the browsers’ built-in list is straightforward, coming off it takes a long time and rides along with browser release schedules.
A quieter mistake is sending the header over plain HTTP, where browsers ignore it entirely. If it is not being served on the encrypted response, it is doing nothing.
Getting it right
Do it last, not first. Make sure every hostname you own has a valid certificate with renewal automated and independently monitored, that plain requests already redirect properly, and that no mixed content remains anywhere on the site.
Then start with a short maximum age and watch for problems for a while before extending it. Add the subdomain instruction only after you have listed every subdomain and confirmed each one is served securely. Treat preloading as a separate decision, taken only when you are certain the hostname will never need to answer over plain HTTP again. Handled in that order it is a sensible last step of a move to HTTPS; handled first it is the reason a site goes dark for the people who visit it most.
