Java Reference
In-Depth Information
Last - Modified: Tue , 15 May 2013 09 : 56 EST
< customer id = "123" >...</ customer >
This initial response from the server is stating that the XML returned is valid for 1,000
seconds and has a timestamp of Tuesday, May 15, 2013, 9:56 AM EST. If the client supports
revalidation, it will store this timestamp along with the cached data. After 1,000 seconds, the
client may opt to revalidate its cache of the item. To do this, it does a conditional GET re-
quest by passing a request header called If-Modified-Since with the value of the cached
Last-Modified header. For example:
GET / customers / 123 HTTP / 1.1
If - Modified - Since: Tue , 15 May 2013 09 : 56 EST
When a service receives this GET request, it checks to see if its resource has been modified
since the date provided within the If-Modified-Since header. If it has been changed since
the timestamp provided, the server will send back a 200, “OK,” response with the new rep-
resentation of the resource. If it hasn't been changed, the server will respond with 304, “Not
Modified,” and return no representation. In both cases, the server should send an updated
Cache-Control and Last-Modified header if appropriate.
ETag
The ETag header is a pseudounique identifier that represents the version of the data sent
back. Its value is any arbitrary quoted string and is usually an MD5 hash. Here's an example
response:
HTTP
HTTP / 1.1 200 OOK
Content-Type : application/xml
Cache-Control : max-age=1000
ETag: "3141271342554322343200"
<customer id="123">...</customer>
Like the Last-Modified header, when the client caches this response, it should also cache
the ETag value. When the cache expires after 1,000 seconds, the client performs a revalida-
tion request with the If-None-Match header that contains the value of the cached ETag . For
example:
GET /customers/123
HTTP / 1.1
If-None-Match: "3141271342554322343200"
/customers/123 HTTP
When a service receives this GET request, it tries to match the current ETag hash of the re-
source with the one provided within the If-None-Match header. If the tags don't match, the
Search WWH ::




Custom Search