<$BlogRSDUrl$>

Tuesday, March 14, 2006

Optimistic Locking for AJAX 

Dan Kubb
Each time an AJAX app fetches a resource, it could make note of the resource's Last-Modified and ETag headers. Later on when changing the same resource those headers would be sent by the AJAX app in the If-Unmodified-Since and If-Match headers respectively, along with the request. Effectively this is saying to the server "Only perform the operation if the copy of the server state matches what I saw last time"... That means Optimistic Locking for AJAX apps using plain old HTTP. Another nice part of this is that if the browser is doing a GET request, and the server state hasn't changed then the server will simply return a 304 Not Modified response. This skips the rendering of the view, and almost no data is sent along the wire to the browser. The browser will just render what it had cached locally, which as you can imagine is extremely fast all around.

Topics: Ajax | Rest | Techniques


Links to this post:

<\$BlogItemBacklinkCreate\$>

Comments: Post a Comment

This page is powered by Blogger. Isn't yours?