Etags

  • ETags, or entity tags, are a mechanism used in HTTP to determine whether a cached resource is still up to date. They are used to validate cached representations of a resource, to avoid unnecessary data transfer.

  • An ETag is a unique identifier that is assigned to a specific version of a resource. When a client requests a resource, the server sends back the resource along with its ETag. The client can then cache the resource and store the ETag.

  • When the client wants to access the resource again, it sends a request to the server with the ETag it received earlier. The server compares the ETag sent by the client with the current ETag of the resource. If the ETags match, the server sends back a "304 Not Modified" response, indicating that the resource has not been modified and the client can use its cached copy. If the ETags do not match, the server sends back the updated resource and a new ETag.

  • ETags are typically generated by the server using a hash function, based on the resource's content and other metadata such as its last modification date. They are often used in conjunction with caching headers such as "Last-Modified" and "Expires" to optimize the performance of web applications.

  • It is worth noting that ETags are not guaranteed to be unique for each version of the resource, and it may not be appropriate for all use cases.

  • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

Last updated

Was this helpful?