我正在读这篇文章post来自 Alex Maccaw,他说:
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 POST 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 POST, 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.
但是 HTTP 规范 Sec 8.1.2.2 Pipelining 说:
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.
那么,Spine 真的“管道”POST 吗?
最佳答案
Maccaw 对术语“管道”的使用和 HTTP 规范中的使用并不相同。事实上,他们是相反的。
在 HTTP 规范中,术语“管道”意味着发送多个请求而不等待响应。 See section 8.1.2.2 .
A client that supports persistent connections MAY "pipeline" its requests (i.e., send multiple requests without waiting for each response).
根据此定义,您可以明白为什么规范强烈反对管道化非幂等请求,因为管道化请求之一可能会更改应用程序的状态,从而产生意外结果。
当Maccaw写到spine的“管道化”时,他实际上指的是解决方案,即客户端将“管道化”请求而不等待响应,如下所示根据 HTTP 规范。也就是说,spinejs 会将请求排队并串行提交,每个连续的请求仅在其前一个请求完成后才会发出。
关于javascript - pine.js:真的是 'pipeline' POST 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16290134/