Domain.Posture
← blog

Use strict-origin-when-cross-origin for Referrer-Policy

· referrer-policy · security-headers · privacy · referer · http-headers

referrer-policysecurity-headersprivacyrefererhttp-headers

For almost every site, the right answer is strict-origin-when-cross-origin — which is also the default modern browsers apply when no policy is set. It sends the full URL as the Referer header on same-origin requests, sends only the origin (scheme, host, port — no path or query) on cross-origin requests, and sends nothing at all when navigating from HTTPS to HTTP. That combination keeps analytics useful within your own site while preventing paths, query strings, and tokens from leaking to third parties or downgraded connections. You set it once as a header:

Referrer-Policy: strict-origin-when-cross-origin

The spectrum of policies

Referrer-Policy values trade privacy against how much referrer data downstream tools receive. From most private to least:

  • no-referrer — never send Referer. Maximum privacy; breaks analytics and any backend that reads the referrer.
  • same-origin — full URL to your own origin, nothing cross-origin.
  • strict-origin — only the origin, and only when not downgrading to HTTP. Never sends a path, even same-origin.
  • strict-origin-when-cross-origin — the recommended default: full URL same-origin, origin-only cross-origin, nothing on downgrade.
  • origin-when-cross-origin — like the above but still leaks the origin even on an HTTPS-to-HTTP downgrade.
  • no-referrer-when-downgrade — the legacy default: full URL everywhere except on downgrade. Leaks full paths and queries to every cross-origin destination.
  • unsafe-url — full URL always, including on downgrade. Leaks the most; avoid it.

There is also origin (always send origin only) and the empty value (fall back to the browser default).

The privacy-versus-analytics tradeoff

The reason strict-origin-when-cross-origin is the sweet spot: the full URL — including paths and query parameters that may carry session ids, search terms, or reset tokens — stays inside your own origin, where you already control it. Cross-origin destinations learn only that a visit came from your domain, not which page. That is usually enough for referral attribution while denying third parties (ad networks, embedded widgets, outbound links) the rest of the URL.

If you genuinely need full cross-origin referrers for an analytics integration, prefer scoping the relaxation to specific links rather than weakening the whole site, and never use unsafe-url, which sends full URLs over insecure connections too.

Setting it: header, meta, or per-link

You can apply the policy at three scopes:

  • HTTP header (site-wide, recommended): Referrer-Policy: strict-origin-when-cross-origin.
  • HTML <meta> for static pages without header control: a meta element with name="referrer" and content="strict-origin-when-cross-origin".
  • Per-link override with the referrerpolicy attribute on a, img, link, or iframe, or rel="noreferrer" to strip the referrer for a single link.

The header wins as the baseline; element-level attributes refine individual requests. Setting the header explicitly is still worth doing even though browsers default to this value, because it documents intent and protects users on older clients.

Check your security headers →

Further reading

Frequently asked questions

What does strict-origin-when-cross-origin Referrer-Policy do?
It sends the full URL on same-origin requests, only the domain origin on cross-origin requests, and nothing when navigating from HTTPS to HTTP. This keeps analytics useful while preventing sensitive data like paths and tokens from leaking to third parties.
How do I set Referrer-Policy on my website?
Set it as an HTTP header: `Referrer-Policy: strict-origin-when-cross-origin`. You can also use an HTML meta tag, or apply `referrerpolicy` attributes to individual links, images, or iframes.
What's the difference between no-referrer and strict-origin-when-cross-origin?
no-referrer never sends any referrer data and breaks analytics; strict-origin-when-cross-origin sends limited data only when safe, balancing privacy with analytics utility. It's the recommended middle ground for most sites.