包含脚本,使用CDN(Google)或将它们本地存储在网站根目录中的速度更快? [英] What's faster for including scripts, using CDN (Google) or storing them locally in website's root?
问题描述
包含脚本,使用CDN(Google)或将它们本地存储在网站根目录中的速度更快? 如果你的意思是核心jQuery库,使用谷歌CDN 作为面向互联网的网站(相反到内部)。
CDN具有以下难以与之竞争的优势:
尽管您可以像配置缓存标头一样配置缓存标头,但您可能无法更快地提供文件。话虽如此,图书馆/ CDN只是难题的一部分。您拥有的杂项插件和代码也应该缩小,合并和通过gzip提供。
What's faster for including scripts, using CDN (Google) or storing them locally in website's root?
If you mean the core jQuery libraries, use the google CDN for an internet-facing site (as opposed to an internal one).
The CDN has the following advantages you'll find hard to compete with:
- More servers
- The bandwidth (you don't pay for)
- Geolocation (lower response time)
- Redundancy
- The optimized caching settings
- Chance the user has already cached the file from there
- Parallelized downloads, user can grab other content from your site at the same time
Though you can configure the cache headers just like they do, you probably can't serve the file faster. That being said, the library/CDN is only part of the puzzle. Miscellaneous plugins and code you have should also be minified, combined and served via gzip.
这篇关于包含脚本,使用CDN(Google)或将它们本地存储在网站根目录中的速度更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!