1

So basically I want to understand the working of ETag token value in If-None-Match header in the request.

I have understood the working of If-modifies-since conditional GET method. Can someone explain in simple terms how Conditional GET work in the case of an Etag with If-None-Match condition?

Thanks in advance :)

this.that
  • 97
  • 1
  • 1
  • 9

1 Answers1

1

For doing conditional requests you use If-None-Match passing an Etag or If-Modified-Since using a date.

A Etag is a value that represents the state of an entity. Usually, it is a base64encoded hash. The server may attach an EtagHTTP header to the response when requesting a resource, such Etag would represent the state of the resource. Then the client may send an Etag or collection of Etags in the If-None-Match header in next requests, so the server will check if the state of the requested resource has changed, and if so it will return HTTP 200 with the new resource representation or otherwise a HTTP 304 indicating that the resource did not change.

An Etag is considered a strong validator, so If-None-Match will take preference over If-Modified-Since.

More info:

Community
  • 1
  • 1
vtortola
  • 34,709
  • 29
  • 161
  • 263
  • it doesn't represent the state of an entity. It represents the content. While the most accurate way to represent this would be a hash of the content, this is rather expensive to compute at run time, hence most servers use other methods; apache/lighttpd use one or more of the file inode, mtime and size, nginx only the last modified time and size. This adds complications on a cluster. Whether conditional requests add any value for most traffic is debatable, it certainly doesn't help in implementing an effective caching strategy for regularly changing content (except for very large files) – symcbean Oct 28 '15 at 21:53