HTTP Header Reference

Searchable reference of the HTTP request and response headers that matter for security, caching and proxying, with recommended values.

Reference Web & Protocol Testing Runs in your browser
Try:

Result

Headers shown
26 of 26

Headers

HeaderDirectionExample valueNotes
Strict-Transport-SecurityResponsemax-age=31536000; includeSubDomainsForces HTTPS for the specified period. Test includeSubDomains carefully - it applies to every subdomain.
Content-Security-PolicyResponsedefault-src 'self'The strongest defence against XSS. Start in Report-Only mode.
X-Content-Type-OptionsResponsenosniffStops the browser guessing content types. Always set it.
X-Frame-OptionsResponseSAMEORIGINLegacy clickjacking protection; superseded by CSP frame-ancestors.
Referrer-PolicyResponsestrict-origin-when-cross-originLimits URL leakage to third parties.
Permissions-PolicyResponsegeolocation=(), camera=()Disables browser features the site does not use.
Cache-ControlBothpublic, max-age=31536000, immutableThe primary caching control. immutable suits fingerprinted assets.
ETagResponseW/"abc123"Validator for conditional requests; pairs with If-None-Match.
VaryResponseAccept-EncodingTells caches which request headers change the response. Omitting it causes wrong cache hits.
Content-EncodingResponsebr, gzipCompression applied to the body.
Transfer-EncodingResponsechunkedStreaming without a known length. Mismatches with Content-Length enable request smuggling.
Content-LengthBoth1234Body size in bytes.
HostRequestexample.comRequired in HTTP/1.1; selects the virtual host.
AuthorizationRequestBearer eyJ...Credentials. Only ever over TLS.
CookieRequestsession=abcClient state. Watch total header size limits.
Set-CookieResponseid=x; Secure; HttpOnly; SameSite=LaxAlways set Secure and HttpOnly; SameSite mitigates CSRF.
X-Forwarded-ForRequest203.0.113.9, 10.0.0.1Client chain through proxies. Trust only the hops you control.
X-Forwarded-ProtoRequesthttpsOriginal scheme behind a terminating proxy - required for correct redirects.
X-Real-IPRequest203.0.113.9nginx convention for the immediate client address.
ForwardedRequestfor=203.0.113.9; proto=httpsThe standardised (RFC 7239) replacement for the X-Forwarded-* family.
Access-Control-Allow-OriginResponsehttps://app.example.comCORS. Never combine a wildcard with credentials.
Retry-AfterResponse120Accompanies 429 and 503 to tell clients when to retry.
Alt-SvcResponseh3=":443"; ma=86400Advertises HTTP/3 availability.
Upgrade-Insecure-RequestsRequest1Client prefers HTTPS variants of subresources.
ServerResponsenginxSoftware identification - minimise or remove it.
Expect-CTResponsemax-age=0Deprecated; Certificate Transparency is now enforced by browsers directly.
nginx baseline security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Content-Security-Policy "default-src 'self'" always;
HSTS is one-way
Set HSTS only once HTTPS works everywhere, including every subdomain if you use includeSubDomains. Browsers cache the policy for the full max-age and there is no practical way to undo it early.

About HTTP Header Reference

Headers carry most of HTTP's behaviour: caching, security policy, content negotiation and the proxy chain. This is the working set, with the values worth defaulting to and the traps that follow from getting them wrong.

Trusting the forwarded chain

X-Forwarded-For is a list, appended to by each proxy, and a client can pre-populate it with anything it likes. The only trustworthy entries are those added by proxies you control, counting backwards from your own edge. Configure your application with the number of trusted hops (nginx set_real_ip_from, Express trust proxy) rather than reading the leftmost value, which is attacker-controlled. Getting this wrong turns rate limiting and IP allow-lists into decoration.

The Vary header, and why caches misbehave

If a response differs based on a request header - Accept-Encoding, Accept-Language, Authorization - the cache must be told with Vary. Omit it and a shared cache will happily serve a gzipped response to a client that cannot decompress, or one user's personalised page to another. It is the single most common cause of "the CDN is serving the wrong content".

Common use cases

  • Building a baseline security header set for a new site.
  • Diagnosing a caching problem at a CDN or reverse proxy.
  • Working out which forwarded header your proxy chain actually sets.

Edge cases and gotchas

  • Access-Control-Allow-Origin: * cannot be combined with credentials - browsers reject the combination.
  • Trust X-Forwarded-For only from proxies you control; clients can forge it.

Frequently asked questions

Do I still need X-XSS-Protection?
No. Browsers removed the XSS auditor it controlled, and it is now inert at best. A Content-Security-Policy is the mechanism that actually mitigates XSS.
X-Frame-Options or CSP frame-ancestors?
Set both for now. frame-ancestors is the modern control and supports multiple origins; X-Frame-Options covers older clients that ignore CSP.