HTTP是一個簡單的協定。客戶程序建立一條同伺服器程序的 T C P連接配接,然後送出請求并讀取伺服器程序的響應。伺服器程序關閉連接配接表示本次響應結束。伺服器程序傳回的檔案通常含有指向其他伺服器上檔案的指針(超文本連結)。使用者顯然可以很輕松地沿着這些連結從一個伺服器到下一個伺服器。
HTTP管線化
HTTP管線化是将多個HTTP要求(request)整批送出的技術,而在傳送過程中不需先等待服務端的回應。管線化機制須通過永久連接配接(persistent connection)完成,僅HTTP/1.1支援此技術(HTTP/1.0不支援),并且隻有GET和HEAD要求可以進行管線化,而POST則有所限制。此外,初次建立連接配接時也不應啟動管線機制,因為對方(伺服器)不一定支援HTTP/1.1版本的協定。
浏覽器将HTTP要求大批送出可大幅縮短頁面的加載時間,特别是在傳輸延遲(lag/latency)較高的情況下(如衛星連接配接)。此技術之關鍵在于多個HTTP的要求消息可以同時塞入一個TCP分組中,是以隻送出一個分組即可同時發出多個要求,借此可減少網絡上多餘的分組并降低線路負載。
[摘自W3C]
在永久連接配接或者HTTP pipelining出現之前,每個連接配接的擷取都需要建立一個獨立的TCP連接配接。
Prior to persistent connections, a separate TCP connection was established to fetch each URL, increasing the load on HTTP servers and causing congestion(擁塞) on the Internet.
[摘自維基百科]
HTTP pipelining可以吧多個http請求輸出到一個socket連接配接(倘若是基于socket的話,更确切的說應該是輸出到一個傳輸層連接配接,在tcp ip中即為TCP連接配接)中去,然後等到對應的響應。
HTTP pipelining is a technique in which multiple HTTP requests are written out to a single socket without waiting for the corresponding responses. Pipelining is only supported in HTTP/1.1, not in 1.0.
The pipelining of requests results in a dramatic improvement in page loading times, especially over high latency connections such as satellite Internet connections.
Since it is usually possible to fit several HTTP requests in the same TCP packet, HTTP pipelining allows fewer TCP packets to be sent over the network, reducing network load.
Non-idempotent(非幂等) methods like POST should not be pipelined. Sequences of GET and HEAD requests can be always pipelined. A sequence of other idempotent requests like GET, HEAD, PUT and DELETE can be pipelined or not depending on whether requests in the sequence depend on the effect of others.[1]
HTTP pipelining requires both the client and the server to support it. HTTP/1.1 conforming servers are required to support pipelining. This does not mean that servers are required to pipeline responses, but that they are required not to fail if a client chooses to pipeline requests.
Implementation in web servers
Implementing pipelining in web servers is a relatively simple matter of making sure that network buffers are not discarded between requests. For that reason, most modern web servers handle pipelining without any problem.
Exceptions include IIS 4.
Implementation in web browsers
HTTP pipelining is disabled in most browsers.
Opera has pipelining enabled by default. It uses heuristics to control the level of pipelining employed depending on the connected server.
Internet Explorer 8 does not pipeline requests, due to concerns regarding buggy proxies and head-of-line blocking.
Mozilla browsers (such as Mozilla Firefox, SeaMonkey and Camino), support pipelining however it is disabled by default.It uses some heuristics(測試試探), especially to turn pipelining off for IIS servers. does the same thing as Firefox.
Konqueror 2.0 supports pipelining, but it's disabled by default.
Google Chrome does not support pipelining.
Implementation in web proxies
Most HTTP proxies do not pipeline outgoing requests.
Some versions of the Squid web proxy will pipeline up to two outgoing requests. This functionality has been disabled by default and needs to be manually enabled for "bandwidth management and access logging reasons."Squid supports multiple requests from clients.
The Polipo proxy pipelines outgoing requests.
本文轉自 dogegg250 51CTO部落格,原文連結:http://blog.51cto.com/jianshusoft/626670,如需轉載請自行聯系原作者