if-match if-none-match
http://developer.netflix.com/docs/REST_API_Conventions
Resource Cache and Concurrency Control
HTTP entity tags, or ETags, help ensure caching and concurrency control for API resources. When an ETag is associated with a resource, you can use the ETag value to ask the Netflix API if your version of a resource is the latest version or whether it has changed since you last retrieved it. When the Netflix API responds to an HTTP
POST
or PUT
request to a resource that accepts such requests, it always returns an ETag in the ETag HTTP header and an etag
element in its response (both with the same value).
To implement cache control by using ETags, you need to query the server to see if the previously-returned, cached resource still matches the state of the current resource on the server. To do so, you include an
If-None-Match
header and set its value to the value of the ETag that accompanied your cached resource value when you retrieved it from the Netflix API. For example, you might have the following:
If-None-Match: "etag_value"
For example, if the ETag value was "
xyzzy
", the above code would look as follows:
If-None-Match: "xyzzy"
If the ETag value that you pass in this request matches the ETag value of the current resource on the server, the Netflix API replies with an HTTP response code of 304 (Not Modified), indicating that the resource on the server has not changed. However, if the ETag value you pass in does not match the ETag value for the resource on the server, then the Netflix API returns a resource response with a new ETag value.
Similarly, you can use ETags to implement concurrency control for resources that support such control and that use
POST
and PUT
requests. To do so, include an If-Match
header and pass the ETag value from a previous response, as follows:
If-Match: "etag_value"
The server accepts the request if the ETag value that you pass with the request matches that of the current resource on the server. However, if the two ETag values do not match, the server returns an HTTP response code of 412 (Precondition Failed).
For resources that support concurrency control you can also use the
etag
parameter to pass the ETag value as part of the resource request rather than as a separate header metadata item, like this:http://api-public.netflix.com/
…&etag=etag_value&
…
0 Comments:
Post a Comment
<< Home