home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Webmaster in a Nutshell

Previous Chapter 19 Next
 

19. HTTP Headers

HTTP headers are used to transfer all sorts of information between client and server. There are four different categories of headers:

General

Information not related to the client, server, or HTTP

Request

Preferred document formats and server parameters

Response

Information about the server sending the response

Entity

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.

19.1 General Headers

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

Cache-Control: directives

Specifies caching directives in a comma-separated list.

Cache request directives

no-cache

Do not cache.

no-store

Remove information promptly after forwarding.

max-age = seconds

Do not send responses older than seconds.

max-stale [ = seconds ]

Send expired data. If seconds are specified, only send data expired by less than the specified number of seconds.

min-fresh = seconds

Send data only if still fresh after the specified number of seconds.

only-if-cached

Do not retrieve new data. Only return data already in the cache. Useful unless the network connection is down.

Cache response directives

public

Cachable by any cache.

private

Not cachable by a shared cache.

no-cache

Do not cache.

no-store

Remove information promptly after forwarding.

no-transform

Do not convert data.

must-revalidate

Client must revalidate the data.

proxy-revalidate

Client must revalidate data except for private client caches.

max-age=seconds

The document should be considered stale in the specified number of seconds.

Connection

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

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

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

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

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

Upgrade: protocol/version

Specifies the preferred communication protocols. Used in conjunction with response code 101 Switching Protocols. For example:

Upgrade: HTTP/1.2

Via

Via: protocol host [comment] ...

Used by gateways and proxies to indicate the protocols and hosts that processed the transaction between client and server.


Previous Home Next
Server Response Codes Book Index Client Request Headers

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell