Sitewalk / Guides / Issue guides / HSTS header

HSTS header: how to check yours and set it to one year

HSTS (Strict-Transport-Security) tells a browser: only ever use HTTPS for this site. It closes one gap that a plain redirect from HTTP to HTTPS leaves open.

Does your site send it?

curl -I https://yoursite.com/

Look for strict-transport-security: max-age=31536000. No line means missing. A smaller number means the protection lapses sooner than the usual advice.

Why it matters

The browser only learns about HSTS after one secure visit. Until then, a first visit that starts on http:// can be intercepted before the redirect. max-age is how many seconds the browser remembers the rule. Per MDN, the header is ignored if it is sent over plain HTTP, and every new response pushes the expiry date forward.

How to fix it

  1. Make sure the whole site works on HTTPS and http:// redirects to https:// with a 301.
  2. Send the header on HTTPS responses only: Strict-Transport-Security: max-age=31536000.
  3. If you are unsure, start with a short value such as 300, check nothing breaks, then raise it.
  4. Add includeSubDomains only when every subdomain works on HTTPS. It applies the rule to all of them.
  5. preload is optional. MDN says it needs a max-age of at least 31536000 and includeSubDomains, and removal from browser lists is slow, so treat it as a late step.

To switch HSTS off, MDN says to send max-age=0 over HTTPS; browsers update only when they next make a secure request.

Set it in your server config, CDN or host settings. Put it in the HTTPS server block only. Tested on nginx and Apache 2.4 on 16 Nov 2026:

# nginx
add_header Strict-Transport-Security "max-age=31536000" always;

# Apache (mod_headers on)
Header always set Strict-Transport-Security "max-age=31536000"

In nginx, a location block that has its own add_header line drops every header set above it, so repeat the headers there.

Check it worked

Run the curl command again and read the value. Then run an audit.

What Sitewalk found on real sites

Our own site sends max-age=31536000 (checked 16 Nov 2026).

Check your whole site in one sentence

Sitewalk checks these headers along with 200+ other technical SEO checks. In ChatGPT, say:

Audit yoursite.com for technical SEO problems

Get started

Checked on 16 Nov 2026. Header behaviour from MDN Web Docs, read 16 Nov 2026. Sitewalk counts are from 87 audited sites, each site's latest audit: a small early-user group, a first look and not a survey.

More guides

All issue guides ยท All guides