In a web application that has a significant ajax component, where is the best place for the client-side concurrency responsibility to lie?
We're trying to use MVC on both the server application (LAMP stack) and the client application (ajax, mostly jQuery and unobtrusive js).
On the server-side, our model throws an exception if it finds a concurrency conflict that it can't solve on it's own. Essentially, the model tracks a revision number and date/user of creation and update. If the object being saved is out of date (older revision than in the data store), it attempts a merge. If it fails, the controller handles the exception and initiates some kind of resolution workflow.
Flow of the page:
- User loads page(ajax application) with initial models--the models are numerous and have many attributes.
- Page polls server for updates every 10-15 seconds--this is for auto-save and getting updates from other users.
- User edits models.
- Any conflicts that arise after initial entry are resolved when the user clicks the "save" button at the bottom of the page.