Skip to content

Commit 4c7eb93

Browse files
authored
Merge pull request #344 from scgbear/ComputingETagGuidanceUpdate
Add additional guidance for ETag computation
2 parents 45eaffc + c6983c7 commit 4c7eb93

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

azure/Guidelines.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,12 +1008,20 @@ When supporting optimistic concurrency:
10081008
#### Computing ETags
10091009
The strategy that you use to compute the `ETag` depends on its semantic. For example, it is natural, for resources that are inherently versioned, to use the version as the value of the `ETag`. Another common strategy for determining the value of an `ETag` is to use a hash of the resource. If a resource is not versioned, and unless computing a hash is prohibitively expensive, this is the preferred mechanism.
10101010

1011+
:ballot_box_with_check: **YOU SHOULD** use a hash of the representation of a resource rather than a last modified/version number
1012+
1013+
> While it may be tempting to use a revision/version number for the resource as the ETag, it interferes with client's ability to retry update requests. If a client sends a conditional update request, the service acts on the request, but the client never receives a response, a subsequent identical update will be seen as a conflict even though the retried request is attempting to make the same update.
1014+
10111015
:ballot_box_with_check: **YOU SHOULD**, if using a hash strategy, hash the entire resource.
10121016

1017+
:ballot_box_with_check: **YOU SHOULD**, if supporting range requests, use a strong ETag in order to support caching.
1018+
10131019
:heavy_check_mark: **YOU MAY** use or, include, a timestamp in your resource schema. If you do this, the timestamp shouldn't be returned with more than subsecond precision, and it SHOULD be consistent with the data and format returned, e.g. consistent on milliseconds.
10141020

10151021
:heavy_check_mark: **YOU MAY** consider Weak ETags if you have a valid scenario for distinguishing between meaningful and cosmetic changes or if it is too expensive to compute a hash.
10161022

1023+
:white_check_box: **DO**, when supporting multiple representations (e.g. Content-Encodings) for the same resource, generate different ETag values for the different representations.
1024+
10171025
### Distributed Tracing & Telemetry
10181026
Azure SDK client guidelines specify that client libraries must send telemetry data through the `User-Agent` header, `X-MS-UserAgent` header, and Open Telemetry.
10191027
Client libraries are required to send telemetry and distributed tracing information on every request. Telemetry information is vital to the effective operation of your service and should be a consideration from the outset of design and implementation efforts.

0 commit comments

Comments
 (0)