是否减少HTTP请求? [英] Reduce HTTP requests or not?
问题描述
一个理论问题:
我们都知道缩小和组合javascript文件的专家,以减少HTTP请求以加速网站。但是当使用流行的javascript库(例如jQuery)时,假设这些库已经从另一个页面下载到客户端计算机并不是太愚蠢。
A theoretical question:
We all know about the pro's of minifying and combining javascript files in order to reduce HTTP requests to speed up a website. But when popular javascript libraries is used (jQuery for instance), it isn't too stupid to assume that these already have been downloaded to the clients computer from another page.
那应该更喜欢什么呢? 行业中的大家伙如何处理它?</ strong>
So what should be preferrered? How does the big guys in the industry handle it?
A)将每个脚本合并并缩小为一个巨大的脚本并提供服务来自我自己的CDN。
B)将所有自编脚本合并到一个文件中,尽可能利用可用的CDN库。 / strong>
B) Combine all "self-written" scripts into one file and utilize available CDN's of libraries where possible.
谢谢!
推荐答案
-
将每个剧本合并并缩小为一个大型剧本并从我自己的CDN
如果你有CDN,我们在说什么? :)你的意思是服务器,对吗?
If you have a CDN, what are we talking about? :) You mean server, right?
业内大公司如何处理它?
大家伙总是使用他们自己的服务器。
The big guys always use their own servers.
...它不是太多愚蠢的假设这些已经从另一个页面下载到客户端计算机。
不幸的是它。事实:
- 40-60% of users have an empty cache experience
- browsers' cache limits are small
- different versions of libraries are in use, cache only happens if they match
- resource from a new domain creates a DNS lookup, which is slow
- +you need to manage dependencies
这篇关于是否减少HTTP请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!