Under conditional GET, the client requests a resource along with an identifier
of the client??™s latest copy, so the server doesn??™t have to send a resource that the
client already has.
One of the most important parts of caching is inexpensively figuring out the identity
of a given entity. In order to determine whether an entity is stale, you must compare
its content with the canonical version on the server. One trivial way to do this would
be to generate and compare the entire response body, but this is ridiculous. It saves
no bandwidth, CPU time, or I/O. We need a shorter way to identify an entity.
The HTTPstandard provides for Entity Tags (usually called ETags, after the HTTP
header in which they are provided), which serve to identify the resource that they
are attached to. You can compare two resources by comparing their ETag. This is
used with conditional GET, where the client sends the ETag associated with its latest
version in an If-None-Match header. The server compares this ETag with that of its
xml application/xml, text/xml, application/x-xml
rss application/rss+xml
atom application/atom+xml
yaml application/x-yaml, text/yaml
multipart_form multipart/form-data
url_encoded_form application/x-www-form-urlencoded
json application/json, text/x-json
Shortcut MIME types
220 | Chapter 7: REST, Resources, and Web Services
latest version; if they match, the client has the latest version and the server renders a
simple 304 Not Modified response.
Pages:
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345