浏覽器預設對同一域下的資源,隻保持一定的連接配接數,會阻塞過多的連接配接。rfc2616建議不超過2個:
Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion.
不同浏覽器的預設值不一樣,對于不同的HTTP協定其值也不一樣。見下表。
浏覽器 | HTTP 1.1 | HTTP 1.0 |
---|---|---|
IE 6,7 | 2 | 4 |
IE 8 | 6 | 6 |
Firefox 2 | 2 | 8 |
Firefox 3 | 6 | 6 |
Safari 3, 4 | 4 | 4 |
Chrome 1,2 | 6 | ? |
Chrome 3 | 4 | 4 |
Opera 9.63,10.00alpha | 4 | 4 |
上表資料來自Steve Souders。
總的來看,HTTP1.0下允許的連接配接數普遍大于HTTP1.1協定下的,是因為HTTP1.1是保持連接配接的,本身對同域下資源的擷取就是優化的,且對資源的消耗要大于HTTP1.0。在rfc2616中說到,限制連接配接數的目的在于提高響應速度和避免擁塞。
修改浏覽器最大連接配接數
1. Firefox
在檔案 X:\Program Files\Mozilla Firefox\greprefs\all.js中,有如下的參數:
// if network.http.keep-alive is true, and if NOT connecting via a proxy, then
// a new connection will only be attempted if the number of active persistent
// connections to the server is less then max-persistent-connections-per-serve r.
pref("network.http.max-persistent-connections-per-server", 6);
// if network.http.keep-alive is true, and if connecting via a proxy, then a
// new connection will only be attempted if the number of active persistent
// connections to the proxy is less then max-persistent-connections-per-proxy .
pref("network.http.max-persistent-connections-per-proxy", 8);
2. IE
需要修改系統資料庫或組政策,詳情見微軟的技術支援。
轉載于:https://www.cnblogs.com/web-backend/archive/2010/05/03/1726835.html