I was reading this <a href="http://alexmaccaw.com/posts/async_ui" rel="nofollow">post</a> from Alex Maccaw, where he states :<blockquote>
The last issue is with Ajax requests that get sent out in parallel. If a user creates a record, and then immediately updates the same record, two Ajax requests will be sent out at the same time, a <strong>POST</strong> and a PUT. However, if the server processes the 'update' request before the 'create' one, it'll freak out. It has no idea what record needs updating, as the record hasn't been created yet.
The solution to this is to pipeline Ajax requests, transmitting them serially. Spine does this by default, queuing up <strong>POST</strong>, PUT and DELETE Ajax requests so they're sent one at a time. The next request sent only after the previous one has returned successfully.</blockquote>
But the HTTP spec <a href="http://www.ietf.org/rfc/rfc2616.txt" rel="nofollow">Sec 18.104.22.168 Pipelining </a> says:<blockquote>
Clients SHOULD NOT pipeline requests using non-idempotent methods or non-idempotent sequences of methods (see section 9.1.2). Otherwise, a premature termination of the transport connection could lead to indeterminate results.</blockquote>
So, does Spine really 'pipeline' POSTs ?Answer1:
Maccaw's usage of the term "pipelineing" and that of the HTTP spec are not the same here. Actually, they're opposite.
In the HTTP spec, the term "pipelining" means sending multiple requests without waiting for a response. <a href="http://www.ietf.org/rfc/rfc2616.txt" rel="nofollow">See section 22.214.171.124</a>.<blockquote>
A client that supports persistent connections MAY "pipeline" its requests (i.e., send multiple requests without waiting for each response).</blockquote>
Based on this definition, you can see why the spec would strongly discourage pipelining non-idempotent requests, as one of the pipelined requests might change the state of the app, with unexpected results.
When Maccaw writes about spine's "pipelining", he's actually referring to <strong><em>the solution</em></strong> to the fact that the client will "pipeline" requests without waiting for a response, as per the HTTP spec. That is, spinejs will queue the requests and submit them serially, each consecutive request being made only after its predecessor completes.