Prev | Current Page 337 | Next

Brad Ediger

"Advanced Rails"

This is preferable to the default Rails ETag method because the if_
modified decision is made before rendering the body, which may be expensive. The
disadvantage is that the list of entities to track must always be passed to if_modified,
and they must generate sensible values for updated_at and etag.
The complement to conditional GET is conditional PUT. Both of them use similar
request and response headers, but they use them toward different ends. While conditional
GET is used to save bandwidth by not resending duplicate response bodies,
* Available from http://labnotes.org/svn/public/ruby/rails_plugins/restfully_yours.
??  updated_on can be used as a synonym for updated_at. In Rails, the _on variants indicate dates, while the _at
variants indicate times.
222 | Chapter 7: REST, Resources, and Web Services
conditional PUT is used to prevent stale updates by making PUT requests conditional
on the previous state of the resource.
In other words, a conditional PUT contains an If-Unmodified-Since or If-Match header
(the exact opposites of the If-Modified-Since and If-None-Match headers, respectively)
with the Last-Modified date or ETag of the last known representation of that
resource. If the server??™s version of the resource (before the requested update) differs
from that requested by the client, the update will be aborted and a 412 Precondition
Failed response code returned.


Pages:
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349