Search code examples
httpodata

What is a strong etag


In the OData world for changing data, there is an optimistic concurrency control that will mark on the http header etag.

The etag value, there are two options available, strong mode and weak mode.

My question, what are difference between these two options?


Solution

  • A weak entity tag consists of an opaque quoted string prefixed by a weakness indicator.

      entity-tag = [ weak ] opaque-tag
      weak       = "W/"
      opaque-tag = quoted-string
    

    Entity tags are used for comparing two or more entities from the same requested resource.

    A "strong entity tag" MAY be shared by two entities of a resource only if they are identical.

    A "weak entity tag," indicated by the "W/" prefix, MAY be shared by two entities of a resource only if the entities are semantically equivalent and could be substituted for each other with no significant change in semantics. A weak entity tag can only be used for weak comparison.

    The example below shows the results for a set of entity-tag pairs and both the weak and strong comparison function results:

    ETag 1  ETag 2  Strong Comparison   Weak Comparison
    ---------------------------------------------------
    W/"1"   W/"1"   no match            match
    W/"1"   W/"2"   no match            no match
    W/"1"   "1"     no match            match
    "1"     "1"     match               match