A web server assigns an ETag, or entity tag, to a specific version of a resource located at a URL. It is a component of HTTP (Hypertext Transfer Protocol), which is used to validate web caches and allows clients to make conditional requests. If the content of the resource at that URL changes, a new ETag is assigned. ETags are similar to fingerprints in that they may be compared rapidly to see if two versions of a resource are identical.
POST
request to the web server for a specific resource.200
and an ETag header.If-None-Match
, the server compares the ETag value in the request header with the ETag identifier on its side.304
(Not Modified) with an empty body, signaling the application to use the cached copy of that specific resource.200
.The three ways to generate ETags are as follows:
In HTTP, ETag value validation is a process used to determine if a client’s cached version of a resource is still valid. The validation process involves comparing the ETag value of the client’s cached version of the resource with the ETag value of the current version of the resource on the server. ETag validation divides into the following two types:
Strong Validation | Weak Validation |
Strong validation (using ETags with "strong" matching) requires that the content of a resource is identical, byte for byte, between the cached version and the server version. This means that if even a tiny part of the resource has changed on the server, such as just one byte, the cached version becomes invalid. In such cases, the client must ask the server for the resource again to get the updated version. | Weak validation (using ETags with "weak" matching) is more flexible than strong validation since it only requires that the resource has not been modified substantially since the cached version was last retrieved. What counts as a substantial change can be defined differently depending on the implementation, but it typically means a noticeable change to the end user. For example, changing the font size on a web page may not be considered a substantial change, but changing the main content of the page would be. |
Overall, strong validation is more strict than weak validation, but can also be more accurate. Weak validation is more flexible, but may not always catch changes that are important to the end user.
Free Resources