HTTP Headers Reference
Common HTTP request, response, caching, cookie, CORS and security headers, with typical values and the mistakes to avoid.
By the tools4free.dev team · Last reviewed 4 December 2026
How to use this reference
An HTTP header is a name and value pair sent before the body of a request or a response. Headers carry the information that is not the content itself: what format the client wants, how long a response may be cached, who the user is, and which security rules the browser should apply. You can see them in the Network panel of any browser's developer tools, or with a command-line client such as curl -i.
Headers belong to one of two directions. Request headers are sent by the client, such as a browser, to the server. Response headers are sent by the server back to the client. A few, such as Content-Type and Content-Length, describe the body and can appear in both directions. Header names are not case-sensitive. Values often carry parameters after a semicolon, for example text/html; charset=utf-8, or a weighted list, for example q=0.8.
This page groups the headers you will meet most often by purpose: content negotiation, caching, authentication, cookies, cross-origin sharing and security. Each table gives a one-line meaning and a typical value. The core semantics are defined in RFC 9110 (HTTP Semantics) and RFC 9111 (HTTP Caching), and MDN documents the browser behaviour. Custom headers used to begin with X-, but that convention was deprecated in 2012 (RFC 6648), and several widely used headers such as X-Frame-Options and X-Content-Type-Options kept the prefix for historical reasons. For the status codes that go with these headers, see the HTTP status codes reference, and for the values of Content-Type, see the MIME types reference.
The headers you will use most
Content-Type, Accept, Authorization, Cache-Control, Set-Cookie, Location, Access-Control-Allow-Origin and Strict-Transport-Security. If something is cached wrongly, look at Cache-Control and Vary first. If a browser refuses a cross-origin call, look at the CORS headers.Request headers
These headers tell the server who is asking and what the client can accept.
| Header | What it does | Example |
|---|---|---|
Host | The host name, and optionally the port, of the server being requested. It lets one server host many sites. | Host: example.com |
User-Agent | Identifies the client software making the request. | User-Agent: curl/8.0 |
Accept | The content types the client can handle, with optional weights. | Accept: text/html, application/json;q=0.9, */*;q=0.8 |
Accept-Encoding | The compression formats the client can decode. | Accept-Encoding: gzip, br |
Accept-Language | The languages the client prefers. | Accept-Language: en-GB, en;q=0.8 |
Authorization | Credentials that authenticate the client with the server. | Authorization: Basic <credentials> |
Cookie | Cookies the browser previously received for this site. | Cookie: session=abc123 |
Origin | The origin (scheme, host and port) that started the request. Used for CORS and some forgery checks. | Origin: https://app.example.com |
Referer | The address of the page that linked to the request. The name is spelt this way because of an early typo. | Referer: https://example.com/page |
Range | Asks for only part of a resource, for example to resume a download. | Range: bytes=0-1023 |
If-None-Match | Makes the request conditional on the ETag not matching. If it matches, the server can answer 304 Not Modified. | If-None-Match: "abc" |
If-Modified-Since | Makes the request conditional on the resource changing after a date. | If-Modified-Since: Wed, 21 Oct 2026 07:28:00 GMT |
Upgrade-Insecure-Requests | Tells the server the client prefers an HTTPS version of the page. | Upgrade-Insecure-Requests: 1 |
Response headers
These headers describe the response and give the client instructions.
| Header | What it does | Example |
|---|---|---|
Content-Type | The media type of the body, with an optional character set. | Content-Type: text/html; charset=utf-8 |
Content-Length | The size of the body in bytes. | Content-Length: 348 |
Content-Encoding | The compression applied to the body. | Content-Encoding: gzip |
Content-Language | The language of the content. | Content-Language: en |
Content-Disposition | Whether to show the content inline or download it as an attachment, and the suggested file name. | Content-Disposition: attachment; filename="report.pdf" |
Location | Where to go next. Used with 201 and with the 3xx redirect codes. | Location: /new-page |
Server | Describes the software that handled the request. | Server: nginx |
Date | When the response was generated. | Date: Wed, 21 Oct 2026 07:28:00 GMT |
Retry-After | How long to wait before retrying. It is either a number of seconds or a date. | Retry-After: 120 |
Allow | The methods the resource supports, typically sent with a 405. | Allow: GET, HEAD |
Accept-Ranges | Whether the server supports range requests. | Accept-Ranges: bytes |
Link | Relationships to other resources, such as preloads. | Link: </style.css>; rel=preload; as=style |
WWW-Authenticate | Tells the client how to authenticate, sent with a 401. | WWW-Authenticate: Basic realm="admin" |
When a response is compressed, Content-Length is the length of the encoded body, not the original file. A Content-Type without a charset can lead to wrong text decoding, so send charset=utf-8 for text types.
Caching headers
Caching headers decide whether a browser or a shared cache such as a CDN may reuse a response without asking the origin again. Caching is defined in RFC 9111. A private cache belongs to one user, like a browser cache. A shared cache serves many users, like a proxy or CDN.
Cache-Control directives
| Directive | Meaning | Example |
|---|---|---|
max-age=N | The response stays fresh for N seconds after it was generated on the origin. | Cache-Control: max-age=604800 |
s-maxage=N | As max-age, but only for shared caches. It overrides max-age and Expires there. | Cache-Control: s-maxage=3600 |
no-cache | The response may be stored, but it must be validated with the origin before every reuse. It does not mean "do not cache". | Cache-Control: no-cache |
no-store | No cache of any kind should store the response. This is the directive for "do not cache". | Cache-Control: no-store |
must-revalidate | Once the response is stale, it must be validated before reuse. | Cache-Control: max-age=600, must-revalidate |
private | Only a private cache may store it. Use it for personalised content. | Cache-Control: private |
public | A shared cache may store it, even if the request used an Authorization header. | Cache-Control: public, max-age=604800 |
immutable | The response will not change while it is fresh, so no revalidation is needed on reload. | Cache-Control: max-age=31536000, immutable |
Validators and related headers
A validator lets a cache ask "has this changed?" and get a short 304 answer instead of the whole body.
| Header | What it does | Example |
|---|---|---|
ETag | An identifier for a specific version of the resource. A W/ prefix marks a weak validator. | ETag: "33a64df5" |
Last-Modified | When the resource last changed. | Last-Modified: Wed, 21 Oct 2026 07:28:00 GMT |
Vary | Lists request headers that change the response, so caches keep separate copies. Vary: * marks the response as uncacheable. | Vary: Accept-Encoding |
Expires | An absolute date after which the response is stale. Cache-Control takes priority. | Expires: Wed, 21 Oct 2026 07:28:00 GMT |
Age | How long the response has been in a shared cache, in seconds. | Age: 24 |
If-Match | Makes a request conditional on the ETag matching. Used to avoid overwriting someone else's change. | If-Match: "33a64df5" |
A common pattern for a website is long caching for files with a hashed name, such as app.3f9a1c.js, and revalidation for the HTML page itself: Cache-Control: max-age=31536000, immutable for the first, and Cache-Control: no-cache with an ETag for the second.
Cookies
The server sets a cookie with Set-Cookie, and the browser returns it in the Cookie request header. The attributes below follow the name and value, separated by semicolons.
| Attribute | Meaning | Example |
|---|---|---|
Secure | Send the cookie only over HTTPS. | Set-Cookie: id=a3fWa; Secure |
HttpOnly | Hide the cookie from JavaScript. It is still sent with requests. | Set-Cookie: id=a3fWa; HttpOnly |
SameSite=Strict | Send the cookie only for requests that start on the same site. | Set-Cookie: id=a3fWa; SameSite=Strict |
SameSite=Lax | Also send it on top-level navigations that use a safe method, such as clicking a link. | Set-Cookie: id=a3fWa; SameSite=Lax |
SameSite=None | Send it on cross-site requests too. Secure must also be set. | Set-Cookie: id=a3fWa; SameSite=None; Secure |
Max-Age, Expires | How long the cookie lives. Without either, it is a session cookie. | Set-Cookie: id=a3fWa; Max-Age=3600 |
Domain, Path | Which hosts and paths the cookie applies to. | Set-Cookie: id=a3fWa; Path=/ |
Cookie names starting with __Host- must be set with Secure, must have no Domain and must use Path=/, which ties the cookie to the exact host. Some browsers treat a cookie as SameSite=Lax when the attribute is missing, so set it explicitly.
Cross-origin resource sharing (CORS)
Browsers block a page from reading a response from another origin unless that server opts in with these headers. A request that needs a permission check first triggers a preflight, an OPTIONS request carrying Access-Control-Request-Method.
| Header | What it does | Example |
|---|---|---|
Access-Control-Allow-Origin | The origin allowed to read the response, or * for any origin on requests without credentials. | Access-Control-Allow-Origin: https://app.example.com |
Access-Control-Allow-Methods | The methods allowed, in a preflight response. | Access-Control-Allow-Methods: GET, POST |
Access-Control-Allow-Headers | The request headers allowed, in a preflight response. | Access-Control-Allow-Headers: Content-Type, Authorization |
Access-Control-Allow-Credentials | Allows the page to send and read cookies and other credentials. The wildcard origin cannot be used with credentials. | Access-Control-Allow-Credentials: true |
Access-Control-Expose-Headers | Extra response headers that scripts may read. | Access-Control-Expose-Headers: ETag |
Access-Control-Max-Age | How long the browser may cache the preflight result, in seconds. | Access-Control-Max-Age: 600 |
If the allowed origin depends on the request, send Vary: Origin too, so a cache does not serve one origin's answer to another.
Security headers
These response headers switch on browser protections. They are cheap to add, and most security scanners look for them. CORS is not a security header in this sense: it relaxes a rule rather than adding one.
| Header | What it does | Example |
|---|---|---|
Strict-Transport-Security | Tells the browser to use HTTPS only for this host in future. Options are max-age, includeSubDomains and preload. Browsers ignore it over plain HTTP. | Strict-Transport-Security: max-age=31536000; includeSubDomains |
Content-Security-Policy | Restricts where scripts, styles, images, frames and other content may load from. Key directives: default-src (the fallback), script-src, style-src, img-src, connect-src, frame-ancestors, form-action, base-uri, object-src and upgrade-insecure-requests. | Content-Security-Policy: default-src 'self'; img-src 'self' data: |
Content-Security-Policy-Report-Only | Same syntax, but violations are reported and not blocked. Good for testing a new policy. | Content-Security-Policy-Report-Only: default-src 'self' |
X-Content-Type-Options | With nosniff, the browser trusts the declared Content-Type and blocks scripts and styles that have the wrong type. | X-Content-Type-Options: nosniff |
X-Frame-Options | Controls whether the page may be shown in a frame, to prevent clickjacking. Values are DENY and SAMEORIGIN. The frame-ancestors CSP directive is the more flexible replacement. It is ignored in a meta tag. | X-Frame-Options: DENY |
Referrer-Policy | How much referrer information to send. The browser default is strict-origin-when-cross-origin. | Referrer-Policy: strict-origin-when-cross-origin |
Permissions-Policy | Allows or denies browser features, such as the camera or geolocation, for the page and its frames. | Permissions-Policy: camera=(), geolocation=() |
Cross-Origin-Opener-Policy | Isolates the page's browsing context from other windows. Values: unsafe-none, same-origin-allow-popups, same-origin and noopener-allow-popups. | Cross-Origin-Opener-Policy: same-origin |
Cross-Origin-Embedder-Policy | Requires embedded resources to opt in. Values: unsafe-none, require-corp and credentialless. | Cross-Origin-Embedder-Policy: require-corp |
Cross-Origin-Resource-Policy | Says who may load this resource. Values: same-site, same-origin and cross-origin. | Cross-Origin-Resource-Policy: same-origin |
Clear-Site-Data | Asks the browser to clear stored data, such as cookies and cache, for the site. Often sent on logout. | Clear-Site-Data: "cache", "cookies" |
X-XSS-Protection is deprecated and non-standard. Modern browsers do not need it when a strong Content-Security-Policy is in place. If you send it at all, the value 0 disables the old filter. A good starting set for a static site is HSTS, a restrictive CSP, nosniff, frame-ancestors or X-Frame-Options, and a Referrer-Policy. Add the cross-origin isolation headers only if you need features that depend on them, because they can break embeds.
Proxy and connection headers
These describe the path a request took, or how the connection behaves.
| Header | What it does | Example |
|---|---|---|
Forwarded | The standard header for details of the original client and request as seen by a proxy. | Forwarded: for=192.0.2.60;proto=https |
X-Forwarded-For | The older, widely used form: the client address followed by each proxy. A client can fake it, so do not trust it without a trusted proxy. | X-Forwarded-For: 203.0.113.5, 198.51.100.7 |
Via | Lists the proxies the message passed through. | Via: 1.1 proxy.example.com |
Connection | Options for the current connection, for example keep-alive or close. | Connection: keep-alive |
Alt-Svc | Advertises that the site is available over another protocol or host, such as HTTP/3. | Alt-Svc: h3=":443" |
Timing-Allow-Origin | Lets other origins read detailed resource timing. | Timing-Allow-Origin: * |
Common mistakes
- Thinking no-cache means no caching. It means "revalidate before reuse". Use
no-storeto keep a response out of caches, for example for pages with account data. - Forgetting Vary. If the response changes with
Accept-Encoding,Accept-LanguageorOrigin, list that header inVary, or a shared cache can serve the wrong version. - Using a wildcard CORS origin with credentials. It is not allowed. Echo the specific origin and add
Vary: Origin. - Sending HSTS before HTTPS works everywhere. Browsers remember the rule for the whole
max-age, and certificate errors cannot be clicked through. Start with a shortmax-age. - Setting security headers in a meta tag.
X-Frame-Optionsdoes not work there. Send it as a real response header. - Trusting X-Forwarded-For blindly. Any client can add it. Use the value only when a proxy you control sets it.
- Missing charset. Without
charset=utf-8on text responses, accented characters can appear garbled.
Authentication tokens often travel in the Authorization header, for example as a bearer token. See JWT explained for what is inside one.
Sources
- RFC 9110: HTTP Semantics
- RFC 9111: HTTP Caching
- RFC 6648: Deprecating the X- prefix
- RFC 6750: The OAuth 2.0 bearer token usage
- MDN: HTTP headers
- MDN: Cache-Control
- MDN: Set-Cookie
- MDN: Strict-Transport-Security
- MDN: Content-Security-Policy
- MDN: X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy
- MDN: Cross-Origin-Opener-Policy, Cross-Origin-Embedder-Policy, Cross-Origin-Resource-Policy
- MDN: Access-Control-Allow-Origin