Skip to content

Warning

Description

The Warning request header is used to carry additional information about the status or transformation of a message. It is primarily used in HTTP responses to indicate potential issues with the response data, such as expiration, transformation, or other warnings that a user agent should consider.

This header is often used in caching mechanisms to alert users about stale or transformed content. The Warning header has been deprecated in HTTP/2 and later versions but is still relevant in some legacy applications.

Syntax

The Warning header follows this syntax:

Warning: <warn-code> <warn-agent> "<warn-text>" [<warn-date>]

Where:

  • <warn-code>: A three-digit warning code.
  • <warn-agent>: The name or pseudonym of the server adding the warning.
  • "<warn-text>": A quoted string containing the warning message.
  • [<warn-date>]: (Optional) A date indicating when the warning was added.

Example Syntax:

Warning: 110 example.com "Response is stale"
Warning: 214 proxy1 "Transformation applied" "Wed, 21 Oct 2015 07:28:00 GMT"

Examples

Stale Response Warning

If a cached response is stale (e.g., beyond its expiration date), the following warning might be added:

Server Response:

HTTP/1.1 200 OK
Cache-Control: max-age=3600
Warning: 110 example.com "Response is stale"

Transformation Warning

If a proxy modifies the response, it can indicate this using a transformation warning:

Proxy Response:

HTTP/1.1 200 OK
Warning: 214 proxy1 "Transformation applied" "Wed, 21 Oct 2015 07:28:00 GMT"

Miscellaneous Warning

If a response is sent with incomplete data, a warning can be issued:

Server Response:

HTTP/1.1 200 OK
Warning: 199 example.org "Miscellaneous warning"

Summary

The Warning request header is used to notify clients about potential issues in HTTP responses, such as stale data or transformations performed by proxies. Though deprecated in HTTP/2, it remains relevant in legacy caching systems and HTTP/1.1 implementations. Understanding and handling the Warning header correctly can help improve transparency in HTTP communications and caching behaviors.