Joe on Entity tags
By sandoz on Mar 26, 2007
I agree with Joe that the "easiest way to think of an etag is as an MD5 or SHA1 hash of all the bytes in a representation". However, a word of warning for those that may get stuck in a little rut of thought like I did. I incorrectly assumed that a representation must always have the same entity tag. Thus if you update a resource, update it again with different content, then update it thrice with the same content as was used for the first update then entity tag has to be the same as that for the first update. But if you read section 3.1.1 of HTTP/1.1 it says:
A "strong entity tag" MAY be shared by two entities of a resource only if they are equivalent by octet equality.
Using a counter and or a last modified date is a very effective way of efficiently creating a strong entity tag. So unlike me don't get too hung up on using a MD5 hash! (unless you need a one-to-one mapping between an entity tag and a representation).
Incidentally the storage service example provided with the RESTful API in R1 of SWDP uses strong entity tags (MD5 hash), see the section at the end on caching. Currently with R1 it is necessary to implement such pre-condition logic yourself, but we have been working on putting such logic into the next revision of the API.