Contents:
General Headers
Client Request Headers
Server Response Headers
Entity Headers
HTTP headers are used to transfer all sorts of information between client and server. There are four different categories of headers:
Information not related to the client, server, or HTTP
Preferred document formats and server parameters
Information about the server sending the response
Information on the data being sent between the client and server
General headers and entity headers are the same for both the server and client.
All headers in HTTP messages contain the header name followed by a colon (:), then a space, and the value of the header. Header names are case-insensitive (thus, Content-Type is the same as Content-type.). The value of a header can extend over multiple lines by preceding each extra line with at least one space or tab.
This chapter covers the most recent draft of the HTTP 1.1 specification that was available at publication time (draft 7), as well as some headers not in the spec but which are in common use regardless.
General headers are used in both client requests and server responses. Some may be more specific to either a client or server message.
Cache-Control: directives
Specifies caching directives in a comma-separated list.
Do not cache.
Remove information promptly after forwarding.
Do not send responses older than seconds.
Send expired data. If seconds are specified, only send data expired by less than the specified number of seconds.
Send data only if still fresh after the specified number of seconds.
Do not retrieve new data. Only return data already in the cache. Useful unless the network connection is down.
Cachable by any cache.
Not cachable by a shared cache.
Do not cache.
Remove information promptly after forwarding.
Do not convert data.
Client must revalidate the data.
Client must revalidate data except for private client caches.
The document should be considered stale in the specified number of seconds.
Connection: options
Specifies options desired for this connection but not for further connections by proxies. The close connection option signifies that either the client or server wishes to end the connection (i.e., this is the last transaction).
Date: dateformat
Indicates the current date and time. The preferred date format is RFC 1123. For example:
Mon, 06 May 1996 04:57:00 GMT
For backwards compatibility, however, the RFC 850 and ANSI C asctime( ) formats are also acceptable:
Monday, 06-May-96 04:57:00 GMT Mon May 6 04:57:00 1996
MIME-Version: version
Specifies the version of MIME used in the HTTP transaction. If a message's entity-body does not conform to MIME, this header can be omitted. If the transaction involves MIME-encoded data, but this header is omitted, the default value is assumed to be 1.0.
Pragma: no-cache
Specifies directives to a proxy system. This header is ignored by the target server. HTTP defines one directive for this header: no-cache. In HTTP 1.0, this tells the proxy to request the document from the server instead of the local cache. HTTP 1.1 prefers using Cache Control: no-cache instead.
Transfer-Encoding: encoding_type
Indicates what type of transformation has been applied to the message body for safe transfer. Currently only the chunked encoding type is defined by HTTP.
Upgrade: protocol/version
Specifies the preferred communication protocols. Used in conjunction with response code 101 Switching Protocols. For example:
Upgrade: HTTP/1.2
Via: protocol host [comment] ...
Used by gateways and proxies to indicate the protocols and hosts that processed the transaction between client and server.