Hubbry Logo
List of HTTP header fieldsList of HTTP header fieldsMain
Open search
List of HTTP header fields
Community hub
List of HTTP header fields
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Contribute something
List of HTTP header fields
List of HTTP header fields
from Wikipedia

HTTP header fields are a list of strings sent and received by both the client program and server on every HTTP request and response. These headers are usually invisible to the end-user and are only processed or logged by the server and client applications. They define how information sent/received through the connection are encoded (as in Content-Encoding), the session verification and identification of the client (as in browser cookies, IP address, user-agent) or their anonymity thereof (VPN or proxy masking, user-agent spoofing), how the server should handle data (as in Do-Not-Track or Global Privacy Control), the age (the time it has resided in a shared cache) of the document being downloaded, amongst others.

General format

[edit]

In HTTP version 1.x, header fields are transmitted after the request line (in case of a request HTTP message) or the response line (in case of a response HTTP message), which is the first line of a message. Header fields are colon-separated key-value pairs in clear-text string format, terminated by a carriage return (CR) and line feed (LF) character sequence. The end of the header section is indicated by an empty field line, resulting in the transmission of two consecutive CR-LF pairs. In the past, long lines could be folded into multiple lines; continuation lines are indicated by the presence of a space (SP) or horizontal tab (HT) as the first character on the next line. This folding was deprecated in RFC 7230.[1]

HTTP/2[2] and HTTP/3 instead use a binary protocol, where headers are encoded in a single HEADERS and zero or more CONTINUATION frames using HPACK[3] (HTTP/2) or QPACK (HTTP/3), which both provide efficient header compression. The request or response line from HTTP/1 has also been replaced by several pseudo-header fields, each beginning with a colon (:).

Field names

[edit]

A core set of fields is standardized by the Internet Engineering Task Force (IETF) in RFC 9110 and 9111. The Field Names, Header Fields and Repository of Provisional Registrations are maintained by the IANA. Additional field names and permissible values may be defined by each application.

Header field names are case-insensitive.[4] This is in contrast to HTTP method names (GET, POST, etc.), which are case-sensitive.[5]

HTTP/2 makes some restrictions on specific header fields (see below).

Non-standard header fields were conventionally marked by prefixing the field name with X- but this convention was deprecated in June 2012 because of the inconveniences it caused when non-standard fields became standard.[6] An earlier restriction on use of Downgraded- was lifted in March 2013.[7]

Field values

[edit]

A few fields can contain comments (i.e. in User-Agent, Server, Via fields), which can be ignored by software.[8]

Many field values may contain a quality (q) key-value pair separated by equals sign, specifying a weight to use in content negotiation.[9] For example, a browser may indicate that it accepts information in German or English, with German as preferred by setting the q value for de higher than that of en, as follows:

Accept-Language: de; q=1.0, en; q=0.5

Size limits

[edit]

The standard imposes no limits to the size of each header field name or value, or to the number of fields. However, most servers, clients, and proxy software impose some limits for practical and security reasons. For example, the Apache 2.3 server by default limits the size of each field to 8,190 bytes, and there can be at most 100 header fields in a single request.[10]

Request fields

[edit]

Standard request fields

[edit]
Name Description Example Status Standard
A-IM Acceptable instance-manipulations for the request.[11] A-IM: feed Permanent RFC 3229
Accept Media type(s) that is/are acceptable for the response. See Content negotiation. Accept: text/html Permanent RFC 9110
Accept-Charset Character sets that are acceptable. Accept-Charset: utf-8 Permanent RFC 9110
Accept-Datetime Acceptable version in time. Accept-Datetime: Thu, 31 May 2007 20:35:00 GMT Provisional RFC 7089
Accept-Encoding List of acceptable encodings. See HTTP compression. Accept-Encoding: gzip, deflate Permanent RFC 9110
Accept-Language List of acceptable human languages for response. See Content negotiation. Accept-Language: en-US Permanent RFC 9110
Access-Control-Request-Method,
Access-Control-Request-Headers
[12]
Initiates a request for cross-origin resource sharing with Origin (below). Access-Control-Request-Method: GET Permanent: standard
Authorization Authentication credentials for HTTP authentication. Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== Permanent RFC 9110
Cache-Control Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain. Cache-Control: no-cache Permanent RFC 9111
Connection Control options for the current connection and list of hop-by-hop request fields.[13]

Must not be used with HTTP/2.[14]

Connection: keep-alive

Connection: Upgrade

Permanent RFC 9110
Content-Encoding The type of encoding used on the data. See HTTP compression. Content-Encoding: gzip Permanent RFC 9110
Content-Length The length of the request body in octets (8-bit bytes). Content-Length: 348 Permanent RFC 9110
Content-MD5 A Base64-encoded binary MD5 sum of the content of the request body. Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== Obsolete[15] RFC 1544, 1864, 4021
Content-Type The Media type of the body of the request (used with POST and PUT requests). Content-Type: application/x-www-form-urlencoded Permanent RFC 9110
Cookie An HTTP cookie previously sent by the server with Set-Cookie (below). Cookie: $Version=1; Skin=new; Permanent: standard RFC 2965, 6265
Date The date and time at which the message was originated (in "HTTP-date" format as defined by RFC 9110: HTTP Semantics, section 5.6.7 "Date/Time Formats"). Date: Tue, 15 Nov 1994 08:12:31 GMT Permanent RFC 9110
Expect Indicates that particular server behaviors are required by the client. Expect: 100-continue Permanent RFC 9110
Forwarded Disclose original information of a client connecting to a web server through an HTTP proxy.[16] Forwarded: for=192.0.2.60;proto=http;by=203.0.113.43 Forwarded: for=192.0.2.43, for=198.51.100.17 Permanent RFC 7239
From The email address of the user making the request. From: user@example.com Permanent RFC 9110
Host The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The port number may be omitted if the port is the standard port for the service requested.

Mandatory since HTTP/1.1.[17] If the request is generated directly in HTTP/2, it should not be used.[18]

Host: en.wikipedia.org:8080

Host: en.wikipedia.org

Permanent RFC 9110, 9113
HTTP2-Settings A request that upgrades from HTTP/1.1 to HTTP/2 MUST include exactly one HTTP2-Settings header field. The HTTP2-Settings header field is a connection-specific header field that includes parameters that govern the HTTP/2 connection, provided in anticipation of the server accepting the request to upgrade.[19][20] HTTP2-Settings: token64 Obsolete RFC 7540, 9113
If-Match Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for methods like PUT to only update a resource if it has not been modified since the user last updated it. If-Match: "737060cd8c284d8af7ad3082f209582d" Permanent RFC 9110
If-Modified-Since Allows a 304 Not Modified to be returned if content is unchanged. If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT Permanent RFC 9110
If-None-Match Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag. If-None-Match: "737060cd8c284d8af7ad3082f209582d" Permanent RFC 9110
If-Range If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity. If-Range: "737060cd8c284d8af7ad3082f209582d" Permanent RFC 9110
If-Unmodified-Since Only send the response if the entity has not been modified since a specific time. If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT Permanent RFC 9110
Max-Forwards Limit the number of times the message can be forwarded through proxies or gateways. Max-Forwards: 10 Permanent RFC 9110
Origin[12] Initiates a request for cross-origin resource sharing (asks server for Access-Control-* response fields). Origin: http://www.example-social-network.com Permanent: standard RFC 6454
Pragma Implementation-specific fields that may have various effects anywhere along the request-response chain. Pragma: no-cache Outdated RFC 9111
Prefer Allows client to request that certain behaviors be employed by a server while processing a request. Prefer: return=representation Permanent RFC 7240
Proxy-Authorization Authorization credentials for connecting to a proxy. Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== Permanent RFC 9110
Range Request only part of an entity. Bytes are numbered from 0. See Byte serving. Range: bytes=500-999 Permanent RFC 9110
Referer [sic] This is the address of the previous web page from which a link to the currently requested page was followed. (The word "referrer" has been misspelled in the RFC as well as in most implementations to the point that it has become standard usage and is considered correct terminology.) Referer: http://en.wikipedia.org/wiki/Main_Page Permanent RFC 9110
TE The transfer encodings the user agent is willing to accept: the same values as for the response header field Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the server it expects to receive additional fields in the trailer after the last, zero-sized, chunk.

Only trailers is supported in HTTP/2.[14]

TE: trailers, deflate Permanent RFC 9110
Trailer The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding. Trailer: Max-Forwards Permanent RFC 9110
Transfer-Encoding The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.

Must not be used with HTTP/2.[14]

Transfer-Encoding: chunked Permanent RFC 9110
User-Agent The user agent string of the user agent. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0 Permanent RFC 9110
Upgrade Ask the server to upgrade to another protocol.

Must not be used in HTTP/2.[14]

Upgrade: h2c, HTTPS/1.3, IRC/6.9, RTA/x11, websocket Permanent RFC 9110
Via Informs the server of proxies through which the request was sent. Via: 1.0 fred, 1.1 example.com (Apache/1.1) Permanent RFC 9110
Warning A general warning about possible problems with the entity body. Warning: 199 Miscellaneous warning Obsolete[21] RFC 7234, 9111

Common non-standard request fields

[edit]
Field name Description Example
Upgrade-Insecure-Requests[22] Tells a server which (presumably in the middle of a HTTP -> HTTPS migration) hosts mixed content that the client would prefer redirection to HTTPS and can handle Content-Security-Policy: upgrade-insecure-requests Upgrade-Insecure-Requests: 1
X-Requested-With Mainly used to identify Ajax requests (most JavaScript frameworks send this field with value of XMLHttpRequest); also identifies Android apps using WebView[23] X-Requested-With: XMLHttpRequest
DNT[24] Requests a web application to disable their tracking of a user. This is Mozilla's version of the X-Do-Not-Track header field (since Firefox 4.0 Beta 11). Safari and IE9 also have support for this field.[25] On March 7, 2011, a draft proposal was submitted to IETF.[26] The W3C Tracking Protection Working Group is producing a specification.[27] DNT: 1 (Do Not Track Enabled)

DNT: 0 (Do Not Track Disabled)

X-Forwarded-For[28] A de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer. Superseded by Forwarded header. X-Forwarded-For: client1, proxy1, proxy2

X-Forwarded-For: 129.78.138.66, 129.78.64.103

X-Forwarded-Host[29] A de facto standard for identifying the original host requested by the client in the Host HTTP request header, since the host name and/or port of the reverse proxy (load balancer) may differ from the origin server handling the request. Superseded by Forwarded header. X-Forwarded-Host: en.wikipedia.org:8080

X-Forwarded-Host: en.wikipedia.org

X-Forwarded-Proto[30] A de facto standard for identifying the originating protocol of an HTTP request, since a reverse proxy (or a load balancer) may communicate with a web server using HTTP even if the request to the reverse proxy is HTTPS. An alternative form of the header (X-ProxyUser-Ip) is used by Google clients talking to Google servers. Superseded by Forwarded header. X-Forwarded-Proto: https
Front-End-Https[31] Non-standard header field used by Microsoft applications and load-balancers Front-End-Https: on
X-Http-Method-Override[32] Requests a web application to override the method specified in the request (typically POST) with the method given in the header field (typically PUT or DELETE). This can be used when a user agent or firewall prevents PUT or DELETE methods from being sent directly (this is either a bug in the software component, which ought to be fixed, or an intentional configuration, in which case bypassing it may be the wrong thing to do). X-HTTP-Method-Override: DELETE
X-ATT-DeviceId[33] Allows easier parsing of the MakeModel/Firmware that is usually found in the User-Agent String of AT&T Devices X-Att-Deviceid: GT-P7320/P7320XXLPG
X-Wap-Profile[34] Links to an XML file on the Internet with a full description and details about the device currently connecting. In the example to the right is an XML file for an AT&T Samsung Galaxy S2. x-wap-profile: http://wap.samsungmobile.com/uaprof/SGH-I777.xml
Proxy-Connection[35] Implemented as a misunderstanding of the HTTP specifications. Common because of mistakes in implementations of early HTTP versions. Has exactly the same functionality as standard Connection field.

Must not be used with HTTP/2.[14]

Proxy-Connection: keep-alive
X-UIDH[36][37][38] Server-side deep packet inspection of a unique ID identifying customers of Verizon Wireless; also known as "perma-cookie" or "supercookie" X-UIDH: ...
X-Csrf-Token[39] Used to prevent cross-site request forgery. Alternative header names are: X-CSRFToken[40] and X-XSRF-TOKEN[41] X-Csrf-Token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
X-Request-ID,[stackoverflow2 1][42]

X-Correlation-ID,[43] Correlation-ID[44]

Correlates HTTP requests between a client and server. Superseded by the traceparent header

[45]

X-Request-ID: f058ebd6-02f7-4d3f-942e-904344e8cde5
Save-Data[46] The Save-Data client hint request header available in Chrome, Opera, and Yandex browsers lets developers deliver lighter, faster applications to users who opt-in to data saving mode in their browser. Save-Data: on
Sec-GPC[47] The Sec-GPC (Global Privacy Control[broken anchor]) request header indicates whether the user consents to a website or service selling or sharing their personal information with third parties. Sec-GPC: 1

Response fields

[edit]

Standard response fields

[edit]
Field name Description Example Status Standard
Accept-CH Requests HTTP Client Hints Accept-CH: UA, Platform Experimental RFC 8942
Access-Control-Allow-Origin,
Access-Control-Allow-Credentials,
Access-Control-Expose-Headers,
Access-Control-Max-Age,
Access-Control-Allow-Methods,
Access-Control-Allow-Headers
[12]
Specifying which web sites can participate in cross-origin resource sharing Access-Control-Allow-Origin: * Permanent: standard RFC 7480
Accept-Patch[48] Specifies which patch document formats this server supports Accept-Patch: text/example;charset=utf-8 Permanent RFC 5789
Accept-Ranges What partial content range types this server supports via byte serving Accept-Ranges: bytes Permanent RFC 9110
Age The age the object has been in a proxy cache in seconds Age: 12 Permanent RFC 9111
Allow Valid methods for a specified resource. To be used for a 405 Method not allowed Allow: GET, HEAD Permanent RFC 9110
Alt-Svc[49] A server uses "Alt-Svc" header (meaning Alternative Services) to indicate that its resources can also be accessed at a different network location (host or port) or using a different protocol

When using HTTP/2, servers should instead send an ALTSVC frame.[50]

Alt-Svc: http/1.1="http2.example.com:8001"; ma=7200 Permanent
Cache-Control Tells all caching mechanisms from server to client whether they may cache this object. It is measured in seconds Cache-Control: max-age=3600 Permanent RFC 9111
Connection Control options for the current connection and list of hop-by-hop response fields.[13]

Must not be used with HTTP/2.[14]

Connection: close Permanent RFC 9110
Content-Disposition[51] An opportunity to raise a "File Download" dialogue box for a known MIME type with binary format or suggest a filename for dynamic content. Quotes are necessary with special characters. Content-Disposition: attachment; filename="fname.ext" Permanent RFC 2616, 4021, 6266
Content-Encoding The type of encoding used on the data. See HTTP compression. Content-Encoding: gzip Permanent RFC 9110
Content-Language The natural language or languages of the intended audience for the enclosed content[52] Content-Language: da Permanent RFC 9110
Content-Length The length of the response body in octets (8-bit bytes) Content-Length: 348 Permanent RFC 9110
Content-Location An alternate location for the returned data Content-Location: /index.htm Permanent RFC 9110
Content-MD5 A Base64-encoded binary MD5 sum of the content of the response Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== Obsolete[15] RFC 1544, 1864, 4021
Content-Range Where in a full body message this partial message belongs Content-Range: bytes 21010-47021/47022 Permanent RFC 9110
Content-Type The MIME type of this content Content-Type: text/html; charset=utf-8 Permanent RFC 9110
Date The date and time that the message was sent (in "HTTP-date" format as defined by RFC 9110) Date: Tue, 15 Nov 1994 08:12:31 GMT Permanent RFC 9110
Delta-Base Specifies the delta-encoding entity tag of the response.[11] Delta-Base: "abc" Permanent RFC 3229
ETag An identifier for a specific version of a resource, often a message digest ETag: "737060cd8c284d8af7ad3082f209582d" Permanent RFC 9110
Expires Gives the date/time after which the response is considered stale (in "HTTP-date" format as defined by RFC 9110) Expires: Thu, 01 Dec 1994 16:00:00 GMT Permanent: standard RFC 9111
IM Instance-manipulations applied to the response.[11] IM: feed Permanent RFC 3229
Last-Modified The last modified date for the requested object (in "HTTP-date" format as defined by RFC 9110) Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT Permanent RFC 9110
Link Used to express a typed relationship with another resource, where the relation type is defined by RFC 8288 Link: </feed>; rel="alternate"[53] Permanent RFC 8288
Location Used in redirection, or when a new resource has been created.
  • Example 1: Location: http://www.w3.org/pub/WWW/People.html
  • Example 2: Location: /pub/WWW/People.html
Permanent RFC 9110
P3P This field is supposed to set P3P policy, in the form of P3P:CP="your_compact_policy". However, P3P did not take off,[54] most browsers have never fully implemented it, a lot of websites set this field with fake policy text, that was enough to fool browsers the existence of P3P policy and grant permissions for third party cookies. P3P: CP="This is not a P3P policy! See https://en.wikipedia.org/wiki/Special:CentralAutoLogin/P3P for more info." Permanent
Pragma Implementation-specific fields that may have various effects anywhere along the request-response chain. Pragma: no-cache Permanent RFC 9111
Preference-Applied Indicates which Prefer tokens were honored by the server and applied to the processing of the request. Preference-Applied: return=representation Permanent RFC 7240
Proxy-Authenticate Request authentication to access the proxy. Proxy-Authenticate: Basic Permanent RFC 9110
Public-Key-Pins[55] HTTP Public Key Pinning, announces hash of website's authentic TLS certificate Public-Key-Pins: max-age=2592000; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="; Permanent RFC 7469
Retry-After If an entity is temporarily unavailable, this instructs the client to try again later. Value could be a specified period of time (in seconds) or a HTTP-date.[56]
  • Example 1: Retry-After: 120
  • Example 2: Retry-After: Fri, 07 Nov 2014 23:59:59 GMT

Permanent

RFC 9110
Server A name for the server Server: Apache/2.4.1 (Unix) Permanent RFC 9110
An HTTP cookie Set-Cookie: CookieName=CookieValue; Max-Age=3600; Version=1 Permanent: standard RFC 6265
Strict-Transport-Security A HSTS Policy informing the HTTP client how long to cache the HTTPS only policy and whether this applies to subdomains. Strict-Transport-Security: max-age=16070400; includeSubDomains Permanent: standard
Trailer The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding. Trailer: Max-Forwards Permanent RFC 9110
Transfer-Encoding The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.

Must not be used with HTTP/2.[14]

Transfer-Encoding: chunked Permanent RFC 9110
Tk Tracking Status header, value suggested to be sent in response to a DNT(do-not-track), possible values:
"!" — under construction
"?" — dynamic
"G" — gateway to multiple parties
"N" — not tracking
"T" — tracking
"C" — tracking with consent
"P" — tracking only if consented
"D" — disregarding DNT
"U" — updated
Tk: ? Permanent
Upgrade Ask the client to upgrade to another protocol.

Must not be used in HTTP/2[14]

Upgrade: h2c, HTTPS/1.3, IRC/6.9, RTA/x11, websocket Permanent RFC 9110
Vary Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server.
  • Example 1: Vary: *
  • Example 2: Vary: Accept-Language
Permanent RFC 9110
Via Informs the client of proxies through which the response was sent. Via: 1.0 fred, 1.1 example.com (Apache/1.1) Permanent RFC 9110
Warning A general warning about possible problems with the entity body. Warning: 199 Miscellaneous warning Obsolete[21] RFC 7234, 9111
WWW-Authenticate Indicates the authentication scheme that should be used to access the requested entity. WWW-Authenticate: Basic Permanent RFC 9110
X-Frame-Options[57] Clickjacking protection: deny - no rendering within a frame, sameorigin - no rendering if origin mismatch, allow-from - allow from specified location, allowall - non-standard, allow from any location X-Frame-Options: deny Obsolete[58]

Common non-standard response fields

[edit]
Field name Description Example
Content-Security-Policy,
X-Content-Security-Policy,
X-WebKit-CSP[59]
Content Security Policy definition. X-WebKit-CSP: default-src 'self'
Expect-CT[60] Notify to prefer to enforce Certificate Transparency. Expect-CT: max-age=604800, enforce, report-uri="https://example.example/report"
NEL[61] Used to configure network request logging. NEL: { "report_to": "name_of_reporting_group", "max_age": 12345, "include_subdomains": false, "success_fraction": 0.0, "failure_fraction": 1.0 }
Permissions-Policy[62] To allow or disable different features or APIs of the browser. Permissions-Policy: fullscreen=(), camera=(), microphone=(), geolocation=(), interest-cohort=()[63]
Refresh Tells the browser to refresh the page or redirect to a different URL, after a given number of seconds (0 meaning immediately); or when a new resource has been created[clarification needed]. Header introduced by Netscape in 1995 and became a de facto standard supported by most web browsers. Eventually standardized in the HTML Living Standard in 2017.[64] Refresh: 5; url=http://www.w3.org/pub/WWW/People.html
Report-To[65] Instructs the user agent to store reporting endpoints for an origin. Report-To: { "group": "csp-endpoint", "max_age": 10886400, "endpoints": [ { "url": "https-url-of-site-which-collects-reports" } ] }
Status CGI header field specifying the status of the HTTP response. Normal HTTP responses use a separate "Status-Line" instead, defined by RFC 9110.[66] Status: 200 OK
Timing-Allow-Origin The Timing-Allow-Origin response header specifies origins that are allowed to see values of attributes retrieved via features of the Resource Timing API, which would otherwise be reported as zero due to cross-origin restrictions.[67] Timing-Allow-Origin: *

Timing-Allow-Origin: <origin>[, <origin>]*

X-Content-Duration[68] Provide the duration of the audio or video in seconds. Not supported by current browsers – the header was only supported by Gecko browsers, from which support was removed in 2015.[69] X-Content-Duration: 42.666
X-Content-Type-Options[70] The only defined value, "nosniff", prevents Internet Explorer from MIME-sniffing a response away from the declared content-type. This also applies to Google Chrome, when downloading extensions.[71] X-Content-Type-Options: nosniff[72]
X-Powered-By[stackoverflow1 1] Specifies the technology (e.g. ASP.NET, PHP, JBoss) supporting the web application (version details are often in X-Runtime, X-Version, or X-AspNet-Version) X-Powered-By: PHP/5.4.0
X-Redirect-By[73] Specifies the component that is responsible for a particular redirect. X-Redirect-By: WordPress
X-Redirect-By: Polylang
X-Request-ID, X-Correlation-ID[stackoverflow2 1] Correlates HTTP requests between a client and server. X-Request-ID: f058ebd6-02f7-4d3f-942e-904344e8cde5
X-UA-Compatible[74] Recommends the preferred rendering engine (often a backward-compatibility mode) to use to display the content. Also used to activate Chrome Frame in Internet Explorer. In HTML Standard, only the IE=edge value is defined.[75] X-UA-Compatible: IE=edge
X-UA-Compatible: IE=EmulateIE7
X-UA-Compatible: Chrome=1
X-XSS-Protection[76] Cross-site scripting (XSS) filter X-XSS-Protection: 1; mode=block

Effects of selected fields

[edit]

Avoiding caching

[edit]

If a web server responds with Cache-Control: no-cache then a web browser or other caching system (intermediate proxies) must not use the response to satisfy subsequent requests without first checking with the originating server (this process is called validation). This header field is part of HTTP version 1.1, and is ignored by some caches and browsers. It may be simulated by setting the Expires HTTP version 1.0 header field value to a time earlier than the response time. Notice that no-cache is not instructing the browser or proxies about whether or not to cache the content. It just tells the browser and proxies to validate the cache content with the server before using it (this is done by using If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match attributes mentioned above). Sending a no-cache value thus instructs a browser or proxy to not use the cache contents merely based on "freshness criteria" of the cache content. Another common way to prevent old content from being shown to the user without validation is Cache-Control: max-age=0. This instructs the user agent that the content is stale and should be validated before use.

The header field Cache-Control: no-store is intended to instruct a browser application to make a best effort not to write it to disk (i.e not to cache it).

The request that a resource should not be cached is no guarantee that it will not be written to disk. In particular, the HTTP/1.1 definition draws a distinction between history stores and caches. If the user navigates back to a previous page a browser may still show you a page that has been stored on disk in the history store. This is correct behavior according to the specification. Many user agents show different behavior in loading pages from the history store or cache depending on whether the protocol is HTTP or HTTPS.

The Cache-Control: no-cache HTTP/1.1 header field is also intended for use in requests made by the client. It is a means for the browser to tell the server and any intermediate caches that it wants a fresh version of the resource. The Pragma: no-cache header field, defined in the HTTP/1.0 spec, has the same purpose. It, however, is only defined for the request header. Its meaning in a response header is not specified.[77] The behavior of Pragma: no-cache in a response is implementation specific. While some user agents do pay attention to this field in responses,[78] the HTTP/1.1 RFC specifically warns against relying on this behavior.

See also

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
HTTP header fields are key-value pairs included in Hypertext Transfer Protocol (HTTP) messages to provide metadata about the message, its payload, or the connection between sender and recipient, enabling functions such as content negotiation, caching, authentication, and resource handling. These fields follow a structured format consisting of a case-insensitive field name followed by a colon and a value, which may be a single token, quoted string, or comma-separated list, as defined in the HTTP/1.1 semantics specification. They are extensible, allowing new fields to be defined while ensuring interoperability through registration, and are divided into end-to-end fields (propagated across intermediaries) and hop-by-hop fields (limited to the next recipient). The complete list of standardized HTTP header fields is maintained in the Hypertext Transfer Protocol (HTTP) Field Name Registry by the (IANA), which as of November 2025 includes 197 entries categorized as permanent (requiring full specification), provisional (under expert review), and deprecated or obsoleted (no longer recommended). Notable permanent fields include Accept (for in requests), Content-Type (specifying media types in responses), Cache-Control (managing caching directives), and (handling access credentials), each defined with precise semantics in IETF RFCs to support secure and efficient web interactions. Provisional fields, such as certain experimental or vendor-specific ones, undergo review before potential permanence, while deprecated entries like Pragma have been superseded by more robust alternatives to address evolving protocol needs.

Fundamentals

General Format

HTTP header fields consist of a case-insensitive field name followed by a colon (":") and a field value, with optional whitespace (OWS) permitted before and after the field name, between the colon and the field value, and at the end of the field value; this OWS is semantically insignificant and ignored during parsing. The overall syntax is defined as field-line = field-name ":" OWS field-value OWS, where the field name is a token (a sequence of characters excluding control characters and separators) and the field value is a sequence of field content or OWS. For instance, a basic header might appear as Host: example.com, Host : example.com (with leading OWS after the name), or Host:example.com (with no OWS around the value), all of which are equivalent. Field values exceeding a single line can employ line folding, where a sender inserts a and line feed (CRLF) followed by OWS to continue the value on the next line; recipients unfold these by replacing the CRLF and OWS with a single or removing them entirely, preserving the original value order. This mechanism, introduced in earlier HTTP specifications and retained for compatibility, allows for more readable transmission of long values without altering semantics. Field names are case-insensitive (e.g., "Content-Type" and "content-type" refer to the same field), but field values are case-sensitive unless the specific field definition states otherwise. The general format originated in HTTP/1.1, where header fields were transmitted as plain text lines in messages, as specified in RFC 7230 (now obsoleted by RFC 9110 and RFC 9112). In , this textual representation is abstracted away by a binary framing layer, where headers are compressed using HPACK and sent in HEADERS or PUSH_PROMISE frames, hiding the traditional line-based format from the wire protocol while maintaining semantic equivalence. further evolves this by mapping headers onto streams, employing QPACK compression instead of HPACK to accommodate QUIC's stream-based, unordered delivery, ensuring efficient transmission without relying on the original text syntax.

Field Names and Values

HTTP header field names are case-insensitive strings composed of one or more token characters, which include uppercase and lowercase letters (A-Z, a-z), digits (0-9), and a limited set of symbols such as hyphen (-), exclamation mark (!), hash (#), dollar sign ($), percent (%), ampersand (&), single quote ('), asterisk (*), plus (+), period (.), caret (^), underscore (_), grave accent (`), vertical bar (|), and tilde (~), while excluding spaces, control characters, and delimiters like parentheses or commas. By convention, field names use lowercase letters separated by hyphens to form multi-word identifiers, such as "content-type" or "user-agent", enhancing readability and consistency across implementations. All field names must be registered in the Internet Assigned Numbers Authority (IANA) Hypertext Transfer Protocol (HTTP) Field Name Registry to avoid collisions and ensure interoperability; permanent registrations require a formal specification and IETF review, while provisional registrations undergo expert review for temporary or experimental use. The use of the "X-" prefix for provisional or experimental field names, once common to denote non-standard extensions, has been deprecated since to prevent namespace pollution and simplify , with implementers advised against making assumptions based solely on the prefix's presence. Since the early implementations of CORS in major browsers (around 2010-2014), "X-" prefixed headers are treated as non-simple and trigger preflight requests unless explicitly allowed by the server via Access-Control-Allow-Headers. Field values follow flexible syntax to accommodate various data types, primarily as tokens for simple identifiers, quoted-strings for text containing special characters, comma-separated lists for multiple items, and parameters for key-value extensions. A token is a sequence of one or more allowed characters without spaces or delimiters, suitable for concise values like directives; for example, the Cache-Control header uses the token value no-cache to indicate that a response must not be used from a cache without revalidation. A quoted-string encloses arbitrary text in double quotes, allowing escaped special characters (e.g., via backslash) within the quotes, which is useful for values with spaces or reserved symbols. Comma-separated lists enable multiple values in a single field, often with optional whitespace around commas, as seen in headers like Accept that list supported media types. Parameters append semicolon-separated name-value pairs to a base value, where the value can be a token or quoted-string; a common example is the q-value parameter in quality-prefixed lists, ranging from 0 to 1 with up to three decimal places to express levels. For instance, the Accept header might specify text/[html](/page/HTML);q=0.8 to indicate a moderate preference for content over other types. These value types build on the general BNF syntax for HTTP messages, allowing parsers to handle structured content reliably while supporting extensibility through registered parameters.

Size Limits and Constraints

HTTP does not impose a strict limit on the size of individual header fields or the total header section in its core specifications. According to RFC 7230 for HTTP/1.1, there is no predefined maximum length for header fields or the overall header block, allowing implementations flexibility while expecting reasonable bounds to prevent resource exhaustion. In practice, web servers enforce per-header limits to mitigate denial-of-service risks; for instance, defaults to 8190 bytes per header field via the LimitRequestFieldSize directive. Similarly, configures a default buffer of 8 KB for client request headers through large_client_header_buffers (typically set to 4 buffers of 8 KB each, enabling up to 32 KB total but often effectively limited to 8 KB without adjustment). For total header sizes in HTTP/1.1, no formal recommendation exists in the RFCs, but common implementations cap the aggregate at around 8 KB to balance performance and security. introduces more structured constraints via its binary framing and header compression (HPACK). The initial flow-control window size is octets (64 KiB), limiting the amount of header data that can be sent before acknowledgment, while the SETTINGS_HEADER_TABLE_SIZE defaults to 4 KB for the compression table but can be negotiated up to 65 KB. Additionally, SETTINGS_MAX_HEADER_LIST_SIZE defaults to an effectively unlimited value (2^31 - 1 bytes), though servers may impose lower practical limits to avoid excessive use. HTTP/3, built over (RFC 9000), inherits similar flexibility but adds transport-layer considerations. Implementations may limit header sizes per message, with no fixed cap in RFC 9114, but the protocol's HEADERS support payloads up to 2^62 bytes in theory; practical deployments often restrict to around 16 KB to align with QUIC's stream flow control and avoid fragmentation. QUIC's frame sizing further constrains headers within stream , typically bounded by the connection's maximum datagram size (default 1200 bytes minimum, up to 64 KB MTU). Line length limits persist from HTTP/1.1 roots; Apache enforces a maximum of 8190 characters per header line, while other servers like NGINX use buffer-based parsing without a hard character cap but reject overflows via configuration. Oversized headers trigger specific error handling to maintain robustness. Servers respond with HTTP 400 Bad Request for general parsing failures, but RFC 6585 defines status code 431 Request Header Fields Too Large specifically for cases where the total request header exceeds server limits, prompting clients to reduce header size. This status is widely adopted in modern servers, including and , to provide clearer feedback than a generic 400.

Request Fields

Standard Request Fields

Standard request fields encompass the officially standardized HTTP header fields, as defined primarily in RFC 9110, that clients include in requests to convey essential metadata to servers, such as target identification, client capabilities, details, and state . These fields enable core protocol functionality, including resource location, , conditional processing for caching, and session management, while evolving with protocol versions like and to use pseudo-headers for efficiency. Among the core fields, the Host header is mandatory for HTTP/1.1 requests and specifies the host and number of the resource being requested, allowing servers to route requests to the correct virtual host. It takes the form of a host name followed optionally by a colon and number, such as Host: example.com:8080. In and , the :authority pseudo-header replaces the Host header, carrying the same authority component but defined as a required pseudo-header field prefixed with a colon to distinguish it from regular headers. The :method pseudo-header, also mandatory in and requests, explicitly declares the HTTP method (e.g., GET, ) as the first header field sent, mapping directly to the traditional method line in HTTP/1.1. The header identifies the client software originating the request, typically including the application name, version, and operating system details to aid servers in optimization and debugging, such as User-Agent: [Mozilla](/page/Mozilla)/5.0 ([Windows NT](/page/Windows_NT) 10.0; Win64; x64). Servers use this for analytics and compatibility checks, though clients are encouraged to limit details to mitigate risks like fingerprinting. The Accept header signals the media types acceptable in the response, using type/subtype pairs with quality factors (e.g., Accept: text/html;q=1.0, application/[json](/page/JSON);q=0.8), enabling proactive based on client preferences. For authentication, the Authorization header transmits credentials to access protected resources, formatted as a scheme followed by encoded credentials (e.g., Authorization: Basic <base64-encoded username:password>), sent in response to a 401 challenge. It supports various authentication schemes like Basic, Digest, or Bearer tokens for APIs. The Cookie header maintains client-side state by returning cookies previously set by the server via Set-Cookie responses, formatted as name-value pairs separated by semicolons (e.g., Cookie: sessionid=abc123; theme=dark), allowing stateless HTTP to simulate sessions. Conditional request fields facilitate efficient caching and resource validation. The If-None-Match header provides one or more entity tags (ETags) to check if the resource has changed, using weak or strong validators; if the server's current ETag matches, it returns 304 Not Modified instead of the full body. Similarly, If-Modified-Since conditions a GET or HEAD request on the resource's last modification date, specified in HTTP-date format (e.g., If-Modified-Since: Sat, 1 Jan 2022 00:00:00 GMT), triggering a 304 response if unchanged since that time. These fields, when combined, prioritize ETag over date-based checks for precision. The Expect header signals client expectations for the server to confirm before proceeding, such as Expect: 100-continue before sending large request bodies. Servers must either send 100 Continue if the expectation is supported or 417 Expectation Failed if not; support for expectations like 100-continue is optional. For data conservation, the Save-Data header, introduced as a client hint in 2021, indicates the user's preference for reduced data usage (e.g., Save-Data: on) to prompt servers to deliver lighter responses, such as lower-resolution images. Fetch metadata headers like Sec-Fetch-Site, Sec-Fetch-Mode, Sec-Fetch-Dest, and Sec-Fetch-User, standardized since 2018, provide servers with contextual details about the request's origin and purpose (e.g., Sec-Fetch-Site: same-origin or Sec-Fetch-Mode: navigate) to enhance decisions, such as blocking cross-site attacks. In , these standard request fields retain the same semantics as in prior versions, with pseudo-headers like :method and :authority integrated into the QUIC-framed messages for improved performance over unreliable networks.

Common Non-Standard Request Fields

Non-standard HTTP request headers, often prefixed with "X-" or used in vendor-specific contexts, have emerged to address practical needs not covered by official RFCs, such as proxy chaining and signaling, though they lack universal interoperability and are sometimes deprecated in favor of standardized alternatives. These headers are commonly implemented by web servers, proxies, and client libraries but can lead to inconsistencies across systems due to their unofficial status. One prominent example is the header, which discloses the original client when requests pass through proxies or load balancers, originating from implementations to preserve client identification in proxied environments. This header appends IP addresses in a comma-separated list, with the leftmost being the initial client, but its non-standard format has prompted security risks like spoofing, leading to recommendations for migration to the standardized Forwarded header defined in RFC 7239. The X-Requested-With header, popularized by the library for detecting AJAX requests by setting its value to "," allows servers to differentiate asynchronous calls from standard navigation, aiding in tailored responses like payloads. However, reliance on this non-standard header has been discouraged since around 2020 due to concerns and lack of broad , with modern alternatives like the Sec-Fetch-Mode header (part of Fetch Metadata Request Headers) providing standardized mode indicators such as "cors" or "navigate." In 2023, Google's Android WebView introduced an opt-in requirement for sending X-Requested-With to enhance user during trials; however, these changes were later cancelled, and as of 2025, the header is sent by default on all requests. The (DNT) header, proposed by the W3C as a mechanism for users to signal preferences against third-party tracking via a value of "1," represents an early attempt at standardized but remains a draft without full ratification, with adoption waning as browsers like and discontinued support by 2025. Despite its non-binding nature, DNT persists in some implementations to communicate user intent for reduced data collection. Vendor-specific extensions include the Sec-CH-UA header family, introduced by in 2020 as part of User-Agent Client Hints to mitigate fingerprinting risks from the traditional User-Agent string, allowing servers to request granular details like browser brand and version only when explicitly opted into via the Accept-CH response header. This approach prioritizes by reducing passive information leakage, with headers like Sec-CH-UA-Mobile indicating device type. More recently, the Global Privacy Control (GPC) header, a proposed specification from 2022 onward backed by advocacy groups, sends a "1" value in requests to enforce user signals across sites, integrating with laws like CCPA and serving as a one-click tool in supported browsers. GPC operates via the GPC request header to signal global consent preferences, though its implementation varies and it complements rather than replaces other mechanisms. Overall, while these non-standard request fields enable practical functionality in diverse ecosystems, their use introduces challenges and potential vulnerabilities, underscoring the importance of transitioning to RFC-defined headers like Forwarded for long-term reliability.

Response Fields

Standard Response Fields

Standard response fields in HTTP are header fields defined in RFCs and registered with the IANA as permanent or provisional, sent by servers to convey metadata, status information, and instructions to clients in responses. These fields play a crucial role in enabling proper interpretation of the response, managing caching, handling redirects, and providing diagnostic details, distinct from request fields which originate from clients. They adhere to the general HTTP header syntax, where field names are case-insensitive and values follow specific formats outlined in relevant RFCs. Among the core standard response fields, the Server field indicates the origin server software that handled the request, such as "Apache/2.4.41 (Ubuntu)", to aid in and compatibility checks. The Date field provides the date and time at which the origin server believes the message was generated, formatted as an HTTP-date in , ensuring synchronized timestamps across systems. The Content-Type field specifies the and optional charset of the representation in the response body, like "text/; charset=", allowing clients to process the content appropriately. The Set-Cookie field instructs the client to store a , containing a name-value pair and attributes like expiration and path, to maintain state across requests. For redirects, the Location field provides the URI of the target resource, mandatory in responses with 3xx status codes to indicate where the client should proceed. Caching-related standard response fields control how and for how long responses are stored by intermediaries and clients. The Cache-Control field carries directives such as "max-age=3600" or "no-cache", dictating caching behavior to balance performance and freshness. The Expires field sets an absolute and time for the response, using HTTP-date format, after which the cached representation is considered stale. The ETag field assigns a unique opaque validator, often an entity tag like "686897696a7c876b7e", for conditional requests to verify if the representation has changed. Additional standard fields address variability, logging, alternatives, and protocol-specific elements. The Vary field lists request header fields, such as "Accept-Encoding", that influence the selected representation, ensuring caches use the appropriate variant key. In HTTP/2 and HTTP/3, the :status pseudo-header field carries the numeric HTTP status code, like 200, and must appear first in the header block before regular fields, replacing the status line from HTTP/1.1. For HTTP/3, basic stream dependencies and prioritization are handled at the QUIC transport layer, with extensible prioritization supported via the dedicated Priority HTTP header field per RFC 9218 to signal client preferences. The Alt-Svc field advertises alternative service endpoints, such as "h2=:443", allowing clients to connect to different hosts or protocols for the same origin, as defined in RFC 7838. The NEL (Network Error Logging) field configures reporting of network errors for the origin, specifying a policy with report URI and maximum age, enabling developers to collect client-side error data. The Warning header, part of HTTP/1.1 semantics, conveyed cautionary information about response freshness or transformations, such as "110 localhost:8080 'Response is stale'" for cache warnings. However, it is deprecated in and later versions per RFC 9111, where header compression and binary framing make its variable-length text inefficient, leading to rare usage in contemporary deployments. X-Content-Type-Options, introduced by in but now a permanent IANA-registered standard field, instructs browsers to strictly honor the Content-Type header without performing type sniffing, using the value "nosniff" to prevent misinterpretation of content that could lead to security exploits like executing scripts from non-script resources. Initially IE-specific, it has been adopted by other browsers including Chrome and to mitigate -based attacks, though it applies primarily to script and style resources. X-Frame-Options, originating from browser vendors to prevent UI redress attacks but now a permanent IANA-registered standard field as specified in RFC 7034, addressed by controlling whether a page could be framed, with directives like "DENY" to block all framing or "SAMEORIGIN" to allow only same-origin embeds. It is transitioning to the more flexible frame-ancestors directive in CSP, with older values like ALLOW-FROM now ignored by modern browsers.

Common Non-Standard Response Fields

Non-standard HTTP response headers, often introduced by browsers, web servers, or frameworks, have filled gaps in the core protocol specifications, providing additional functionality for , , and content handling. These headers, prefixed with "X-" or otherwise non-RFC-defined, gained widespread adoption before or alongside formal standardization efforts, but many face deprecation as HTTP evolves toward versions like and , which prioritize efficiency and modern models. While they enhance server responses in specific scenarios, their non-standard nature can lead to issues, prompting transitions to standardized alternatives. The X-Powered-By header discloses the software or framework generating the response, such as "PHP/8.0.0" or "Express," originating from early implementations like and IIS to aid . This practice poses a risk by revealing the technology stack, enabling attackers to target known vulnerabilities in specific versions, as highlighted in guidelines recommending its removal to minimize disclosure. Content-MD5, which provided a Base64-encoded MD5 checksum of the response body for integrity verification, was defined in early HTTP/1.1 but obsoleted in RFC 7231 due to inconsistent implementations across partial content and proxies, rendering it unreliable for modern use. Servers and clients are advised against generating or relying on it, as it no longer aligns with HTTP's semantics for message integrity. Report-To enabled servers to specify endpoints for browser-generated reports on violations like Content Security Policy (CSP) infractions, using JSON objects to define named endpoint groups such as {"group":"csp-endpoint","max_age":10886400,"endpoints":[{"url":"https://example.com/csp-reports"}]} . As part of the W3C Reporting API, it served as an experimental mechanism for error reporting but has been deprecated in favor of the standardized Reporting-Endpoints header, with limited production support due to its non-standard status. X-XSS-Protection activated built-in XSS filters in browsers like Chrome and , with values such as "1; mode=block" to detect and block reflected XSS attempts by scanning content before rendering. Google removed support in Chrome starting with version 72 in February 2019, following Microsoft's Edge removal in 2018, deeming it obsolete and potentially harmful due to false positives; CSP is now the preferred defense.

Specialized Fields

Security and Privacy Fields

Security and privacy fields in HTTP headers provide mechanisms to enforce secure connections, mitigate content injection attacks, control feature access, and limit information leakage, enhancing overall protection. These headers are typically set in responses but can influence both client and server behaviors, often integrating with underlying transport protocols like TLS. They address vulnerabilities such as man-in-the-middle attacks, (XSS), and unauthorized data sharing, with specifications evolving through standards bodies like the IETF and W3C. Strict-Transport-Security (HSTS), defined in RFC 6797, instructs browsers to interact with a site only over , preventing protocol downgrade attacks and cookie hijacking on insecure connections. The header includes a max-age directive specifying the duration in seconds for which the policy applies, along with optional includeSubDomains to extend protection to subdomains and preload to enable site inclusion in browser preload lists for broader enforcement. For example, Strict-Transport-Security: max-age=31536000; includeSubDomains; preload enforces for a year across subdomains and signals eligibility for preloading. Content-Security-Policy (CSP), standardized in levels 1 through 3 by the W3C, allows developers to declare approved sources for content loading, reducing risks from XSS and other injection vulnerabilities by restricting inline scripts, styles, and external resources. Level 1 (2012) introduced basic directives like default-src, while Level 2 (2016) added reporting and nonce support, and Level 3 (ongoing) enhances nonce reuse and frame-ancestor controls. A key directive, script-src, specifies allowed script sources, such as Content-Security-Policy: script-src 'self' [https](/page/HTTPS)://[example.com](/page/Example.com);, permitting scripts only from the same origin or a trusted domain. Permissions-Policy, the successor to the deprecated Feature-Policy header as per W3C specifications, enables granular control over browser features like geolocation, camera, and fullscreen access, preventing unauthorized use in iframes or subresources. Introduced in , it uses a serialized policy string to allow or disable features, e.g., Permissions-Policy: geolocation=(self "https://example.com"), restricting geolocation to the same origin and a specific domain. Recent working drafts from 2024 introduce finer-grained controls, including container policies for nested browsing contexts and integration with emerging privacy features. Referrer-Policy controls the amount of referrer information sent in the Referer header during navigations and resource fetches, mitigating privacy leaks from URL exposure. Specified by the W3C in 2017, it supports values like no-referrer (no referrer sent), same-origin (referrer only for same-origin requests), or strict-origin-when-cross-origin (origin-only for cross-origin with upgrades to ). For instance, Referrer-Policy: strict-origin-when-cross-origin balances functionality and privacy by omitting paths and queries on cross-origin requests unless secure. Sec-GPC (Global Privacy Control), outlined in a 2022 W3C draft, signals user opt-out preferences for data sales or sharing across sites via a simple HTTP request header, promoting compliance with privacy laws like CCPA. Browsers supporting GPC set Sec-GPC: 1 in requests when the user has enabled the control, allowing servers to honor do-not-sell/share directives without per-site configuration. Cross-Origin-Embedder-Policy (COEP), standardized in the specification following its proposal by the WICG in 2020, enforces cross-origin isolation by requiring embedded resources to opt-in via CORS or CORP headers, enabling access to high-security APIs like SharedArrayBuffer while blocking unsafe embeddings. Values include require-corp (mandating Cross-Origin-Resource-Policy) or credentialless (allowing anonymous fetches), as in Cross-Origin-Embedder-Policy: require-corp, which prevents Spectre-like attacks by isolating origins. Cross-Origin-Opener-Policy (COOP), standardized in the specification following its proposal by the WICG in 2020, controls the relationship between a and its opener or popups to enforce cross-origin isolation, mitigating side-channel attacks like Spectre by managing browsing context groups and restricting cross-origin window access. Values include unsafe-none (default, allows shared context), same-origin-allow-popups (isolates except for same-origin popups), and same-origin (full isolation), as in Cross-Origin-Opener-Policy: same-origin-allow-popups, which permits popup creation while isolating the context for security. It is often used alongside COEP for complete cross-origin isolation. In HTTP/2 and HTTP/3, no dedicated security pseudo-headers exist beyond standard framing, but security integrates deeply with TLS; HTTP/3, per RFC 9114, mandates QUIC's built-in TLS 1.3 encryption for all connections, eliminating unencrypted options and enhancing privacy through integrated crypto handshakes.

Caching and Performance Fields

Caching and performance fields in HTTP headers enable efficient resource management by controlling how responses are stored, transmitted, and retrieved, thereby reducing latency and bandwidth usage across client-server interactions. These headers address key aspects of web performance, including client-side caching strategies to minimize redundant requests and server-side optimizations like content encoding and protocol negotiations to streamline data transfer. By specifying directives for cache validity, freshness, and invalidation, they help balance data freshness with performance gains, while compression and encoding mechanisms further enhance throughput, particularly in modern protocols like HTTP/2 and HTTP/3. The Cache-Control header provides fine-grained control over caching behaviors through various directives. For instance, the max-age directive specifies the maximum age in seconds for a cached response before it must be revalidated, allowing clients to reuse fresh content without contacting the origin server. In contrast, no-store instructs caches to avoid storing the response at all, ensuring sensitive data is not persisted. These directives apply to both requests and responses, promoting efficient caching hierarchies from private browsers to shared proxies. Legacy compatibility is maintained via the Pragma header, where no-cache serves as a deprecated equivalent to Cache-Control's no-cache, signaling that caches must validate responses before use, though it lacks the precision of modern directives. Performance-oriented headers facilitate optimized transmission and protocol enhancements. The Transfer-Encoding header, commonly set to chunked, allows servers to send response bodies in sequential chunks without specifying the total length upfront, which is essential for dynamic content generation and persistent connections. Complementing this, the TE header enables clients to indicate acceptance of trailers—metadata appended after the body—and specific transfer codings like compression, supporting trailers for checksums or late metadata. For protocol upgrades, the Alt-Svc (Alternative Services) header advertises alternative server endpoints or protocols, such as shifting to over the same port, enabling seamless performance improvements without altering the primary URL. In and beyond, header compression plays a pivotal role in performance by mitigating overhead from repeated field transmissions. HPACK, the compression algorithm for , employs a static and dynamic table to encode headers efficiently, reducing redundancy in header blocks and achieving up to 50% size savings in typical scenarios. extends this with QPACK, which adapts HPACK for QUIC's multiplexed streams by separating encoding and decoding to avoid , further optimizing for lossy networks. The Vary header interacts with caching by listing request headers (e.g., Accept-Encoding) that influence response variations, ensuring caches select the appropriate stored variant and preventing cache poisoning. Recent advancements include support for early data transmission to enhance connection resumption. The Early-Data header, defined in RFC 8470 for HTTP over and TLS 1.3's 0-RTT (zero round-trip time) resumption, allows clients to send request payloads immediately upon connection resumption without waiting for server acknowledgment, reducing latency for repeated sessions by up to one full round-trip. In , server-push mechanisms are constrained by the MAX_PUSH_ID frame sent by the client on the control stream, which sets the maximum push ID and thereby limits the number of pushes to prevent resource exhaustion. These fields collectively address performance bottlenecks in evolving web architectures.

Practical Effects

Avoiding Caching

To prevent caching of HTTP responses, servers employ specific directives in the Cache-Control header that instruct caches—whether private (e.g., browser caches) or shared (e.g., proxies and CDNs)—to either avoid storing the response or require revalidation before reuse. The no-cache directive allows storage but mandates validation with the origin server via conditional requests, such as those using If-None-Match or If-Modified-Since headers, ensuring freshness without prohibiting temporary storage. In contrast, the no-store directive explicitly forbids any caching of the response or its metadata, making it suitable for sensitive or highly dynamic content where even temporary storage poses risks. The private directive restricts storage to private caches only, excluding shared caches to maintain user-specific data isolation. For backward compatibility with HTTP/1.0 caches that lack Cache-Control support, the Pragma: no-cache header serves as a fallback, signaling that the response should not be used from cache without revalidation from the origin. This directive, though deprecated in HTTP/1.1, remains effective in mixed-protocol environments to enforce consistent anti-caching behavior across legacy systems. When combined, Cache-Control: no-cache with Pragma: no-cache provides robust prevention, as no-cache permits revalidation while Pragma historically aligns with similar semantics in older implementations. These directives interact with validation mechanisms to refine anti-caching strategies. The must-revalidate directive requires caches to revalidate stale responses immediately upon expiration, preventing use of outdated content even in private contexts, while proxy-revalidate extends this requirement specifically to shared caches for coordinated freshness across intermediaries. Validators like and Last-Modified headers complement these by enabling efficient revalidation; weak validators (prefixed with "W/" for or low-precision timestamps for Last-Modified) allow semantic equivalence checks but may permit caching of byte-range requests only under strict conditions, balancing security with performance. In and later versions, server push allows proactive delivery of resources, but pushed responses respect Cache-Control directives. For no-cache, the response is considered validated by the origin while the push is open, but requires revalidation after the closes. Service workers, as client-side proxies, can further bypass Cache-Control directives by intercepting fetches and managing their own caches via the Cache Storage , effectively ignoring no-cache or no-store instructions unless explicitly handled in the worker's logic. API endpoints often leverage no-store to enforce fresh fetches for dynamic data, such as user sessions or real-time analytics, ensuring each request retrieves the latest state without intermediary storage that could lead to inconsistencies. For instance, RESTful services handling tokens typically include Cache-Control: no-store, private to prevent exposure in shared caches while forcing origin validation. HTTP/3, built over , inherits core caching semantics from prior versions, maintaining semantic equivalence.

Security Implications

Misconfigurations in HTTP header fields can expose web applications to significant security vulnerabilities, often by enabling attackers to intercept traffic, perform reconnaissance, or execute malicious code. For instance, the absence of the Strict-Transport-Security (HSTS) header allows man-in-the-middle (MITM) attacks, where adversaries can downgrade connections to HTTP, intercepting sensitive data such as login credentials. Without HSTS, browsers do not enforce encrypted connections for future visits, increasing the risk of or certificate spoofing. Exposing the Server and User-Agent headers provides attackers with valuable reconnaissance information, revealing software versions and client details that facilitate targeted exploits. For example, disclosing the server type (e.g., Apache 2.4.41) allows attackers to identify known vulnerabilities specific to that version, streamlining phishing or exploit development. Similarly, the User-Agent header can leak browser or device specifics, aiding in crafting client-side attacks like drive-by downloads. Content Security Policy (CSP) misconfigurations, such as including 'unsafe-inline' in the script-src directive, undermine protections against (XSS) by permitting inline execution without validation. This allows attackers to inject and run malicious scripts directly in , bypassing restrictions on external sources and enabling data theft or defacement. The Referer header, when not controlled via Referrer-Policy, leaks full URLs—including sensitive paths like password resets—during cross-site requests, exposing users to or information disclosure. In HTTP/2, the HPACK header compression algorithm was introduced to mitigate compression oracle attacks like , which exploited to infer secrets from response sizes; HPACK uses static and dynamic tables to bound compression ratios and avoid such side-channel leaks. These mitigations were formalized in the 2015 HTTP/2 specification, reducing but not eliminating risks from dynamic compression. HTTP/3 further enforces TLS 1.3 for all connections via , mandating encryption from the outset and preventing protocol downgrade attacks that plagued earlier versions. Such header misconfigurations align with OWASP's A02:2025 – Security Misconfiguration risk (up from A05 in 2021), where improper setup of HTTP headers contributes to broader application weaknesses, noted as more prevalent in recent data. A notable example is the vulnerability (CVE-2021-44228), where attackers injected malicious payloads into HTTP headers like User-Agent, triggering remote code execution if logged by vulnerable instances; exploitation persisted into 2023 and beyond in unpatched systems. In single-page applications (SPAs), client-side header injection via XSS vulnerabilities allows attackers to manipulate outgoing request headers in fetches, potentially bypassing CORS policies or forging tokens to access restricted APIs. This extends reconnaissance and injection risks, as SPAs' heavy reliance on client-side logic amplifies the impact of header-related flaws.

References

Add your contribution
Related Hubs
Contribute something
User Avatar
No comments yet.