Skip to main content

Warning

The "Warning" header field is used to carry additional information about the status or transformation of a message that might not be reflected in the status code. This information is typically used to warn about possible incorrectness introduced by caching operations or transformations applied to the payload of the message.

Warnings can be used for other purposes, both cache-related and otherwise. The use of a warning, rather than an error status code, distinguishes these responses from true failures.

Warning header fields can in general be applied to any message. However, some warn-codes are specific to caches and can only be generated by a cache when validating a cached entry.

Warning = 1#warning-value

warning-value = warn-code SP warn-agent SP warn-text
[ SP warn-date ]

warn-code = 3DIGIT
warn-agent = ( uri-host [ ":" port ] ) / pseudonym
; the name or pseudonym of the server adding
; the Warning header field, for use in debugging.
; A pseudonym SHOULD be the generated hostname.
warn-text = quoted-string
warn-date = DQUOTE HTTP-date DQUOTE

Multiple warnings can be attached to a response (either by the origin server or by a cache), including multiple warnings with the same code number, only differing in warn-text.

A user agent that receives one or more Warning header fields SHOULD inform the user of as many of them as possible, in the order that they appear in the response.

This specification defines the warn-codes described below. The "Warn Code Registry" located at http://www.iana.org/assignments/http-warn-codes is the authoritative source for warn-code values and their meanings.

Any server or cache MAY generate a Warning header field in a response. Warnings are assigned three digit warn-codes. The first digit indicates whether the Warning is required to be deleted from a stored response after validation:

  • A warn-code of 1xx indicates a Warning that describes the freshness or validation status of the response, and so it MUST be deleted after a successful validation. A 1xx warn-code MUST NOT be generated if a validation is performed, regardless of whether or not the validation changes the freshness lifetime of the response.

  • A warn-code of 2xx indicates a Warning that describes some aspect of the representation that is not rectified by a validation (for example, a lossy compression of the representation) and so it MUST NOT be deleted after validation, unless the full response content changes (i.e., the entity-tag associated with the response changes), in which case it MUST be deleted.

When a 1xx warn-code is sent with a stale response, it SHOULD be sent every time a cache sends a stale response, even if the same warning was sent before.

When a 2xx warn-code is sent, it SHOULD be sent every time a cache sends the associated response, even if the same warning has already been sent.

If an implementation sends a message with one or more Warning headers whose version is HTTP/1.0 or lower, then the sender MUST include in each warning-value a warn-date that matches the Date header field in the response.

If an implementation receives a message with a warning-value that includes a warn-date, and that warn-date is different from the Date value in the response, then that warning-value MUST be deleted from the message before storing, forwarding, or using it. This prevents bad consequences of naive caching of Warning header fields.

If all of the warning-values are deleted for this reason, the Warning header field MUST be deleted as well.


Warning = 1#warning-value

warning-value = warn-code SP warn-agent SP warn-text
[ SP warn-date ]

warn-code = 3DIGIT
warn-agent = ( uri-host [ ":" port ] ) / pseudonym
warn-text = quoted-string
warn-date = DQUOTE HTTP-date DQUOTE

Warning = 1#warning-value

warning-value = warn-code SP warn-agent SP warn-text
[ SP warn-date ]

warn-code = 3DIGIT
warn-agent = ( uri-host [ ":" port ] ) / pseudonym
warn-text = quoted-string
warn-date = DQUOTE HTTP-date DQUOTE