An
ETag (entity tag) is part of
HTTPHypertext Transfer Protocol is an application-level protocol for distributed, collaborative, hypermedia information systems. Its use for retrieving inter-linked resources, called hypertext documents, led to the establishment of the World Wide Web in 1990 by English physicist Tim Berners-Lee...
, the protocol for the
World Wide WebThe World Wide Web is a system of interlinked hypertext documents accessed via the Internet. With a web browser, one can view Web pages that may contain text, images, videos, and other multimedia and navigate between them using hyperlinks...
. It is a response header that may be returned by an HTTP/1.1 compliant
web serverThe term web server or webserver can mean one of two things:# A computer program that is responsible for accepting HTTP requests from clients , and serving them HTTP responses along with optional data contents, which usually are web pages such as HTML documents and linked objects .# A computer that...
and is used to determine change in content at a given
URLIn computing, a Uniform Resource Locator is a subset of the Uniform Resource Identifier that specifies where an identified resource is available and the mechanism for retrieving it. In popular usage and in many technical documents and verbal discussions it is often incorrectly used as a synonym...
. When a new HTTP response contains the same ETag as an older HTTP response, the client can conclude that the content is the same without further downloading. The header is useful for intermediary devices that perform
cachingWeb caching is the caching of web documents to reduce bandwidth usage, server load, and perceived lag. A web cache stores copies of documents passing through it; subsequent requests may be satisfied from the cache if certain conditions are met.It should not to be confused with a web archive, a...
, as well as for client web browsers that cache results.
An
ETag (entity tag) is part of
HTTPHypertext Transfer Protocol is an application-level protocol for distributed, collaborative, hypermedia information systems. Its use for retrieving inter-linked resources, called hypertext documents, led to the establishment of the World Wide Web in 1990 by English physicist Tim Berners-Lee...
, the protocol for the
World Wide WebThe World Wide Web is a system of interlinked hypertext documents accessed via the Internet. With a web browser, one can view Web pages that may contain text, images, videos, and other multimedia and navigate between them using hyperlinks...
. It is a response header that may be returned by an HTTP/1.1 compliant
web serverThe term web server or webserver can mean one of two things:# A computer program that is responsible for accepting HTTP requests from clients , and serving them HTTP responses along with optional data contents, which usually are web pages such as HTML documents and linked objects .# A computer that...
and is used to determine change in content at a given
URLIn computing, a Uniform Resource Locator is a subset of the Uniform Resource Identifier that specifies where an identified resource is available and the mechanism for retrieving it. In popular usage and in many technical documents and verbal discussions it is often incorrectly used as a synonym...
. When a new HTTP response contains the same ETag as an older HTTP response, the client can conclude that the content is the same without further downloading. The header is useful for intermediary devices that perform
cachingWeb caching is the caching of web documents to reduce bandwidth usage, server load, and perceived lag. A web cache stores copies of documents passing through it; subsequent requests may be satisfied from the cache if certain conditions are met.It should not to be confused with a web archive, a...
, as well as for client web browsers that cache results. One method of generating the ETag is based on the last modified time of the file and the size of the file, another is using a
checksumA checksum or hash sum is a fixed-size datum computed from an arbitrary block of digital data for the purpose of detecting accidental errors that may have been introduced during its transmission or storage. The integrity of the data can be checked at any later time by recomputing the checksum and...
.
To implement the functionality, the server returns the ETag header:
ETag: "686897696a7c876b7e"
If the client wants to retrieve the page again, and it has a cached version, it sends the If-None-Match header with the ETag of the cached page:
If-None-Match: "686897696a7c876b7e"
If the server determines that this matches the current ETag for that page, then the server returns a
304 Not Modified response with no content.
If the ETag is generated incorrectly, it can lead to updated files not being redownloaded by the user agent, or files that are already in the cache being downloaded again.