Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么将资源放在多个域名下会提升网站的加载速度? #17

Open
FanWalker opened this issue Oct 29, 2017 · 0 comments

Comments

@FanWalker
Copy link
Owner

http1.0/1.1 支持同时发送多个请求,并发请求多个资源当然比一个一个的请求快,可是在同一个域名下,浏览器并发请求的数量是有限制的(chrome为6个),如果有多个同域名的资源,浏览器会等待前面的资源下载完毕,然后复用tcp连接发起后续的请求。

举个例子,访问淘宝首页需要加载上百个资源,浏览器这么小的并发连接数自然会加载很久,所以如果想要要突破限制,前端开发人员会将这些资源分布在多个域名下,使用不同域名来请求资源,变相地绕过浏览器的限制

附上不同浏览器对同一个域名下的静态资源并发加载的数量:

浏览器及版本 最大HTTP并发连接数
IE6 2
IE7 2
IE8(可以在about:config中修改) 6
Chrome 6
Firefox(可以在about:config中修改) 6
Safari 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant