Discovering JavaScript CDN hit rates
Is there any data available on hit rates for the various JavaScript CDNs? It would help to make a decision on which CDN to use.
For example, say my app needs jQuery. Knowing which jQuery copy among the CDNs of Google, MS, CloudFlare and so on are likely to be cached would be useful for performance.
(Anticipating that someone will say this isn't a programming question. Please dear moderator consider that this is a programmer asking a question directly relevant to a programming problem - how do I best satisfy my code's dependencies.)
(Update - Ah yes, as expected, this useful programming question has been marked off-topic because it doesn't "recommend or find a tool, library or favorite off-site resource", even though it doesn't do any of those things. And with no comment. Way to encourage useful questions mods.)
Ultimately it doesn't matter as long as your using a true CDN that has multiple edge locations and that uses proper caching headers on the resources. I say this because all sites don't all use the same jquery version, as you browse around your browser is caching multiple jquery versions from different cdns. Even if they were all the same CDN, there's a growing chance that your browser cache will be purged to make room for new assets due to a full browser disk cache or the resource expiring itself due to max age. The goal is to make your returning or frequent visitors happy using a properly cached site.
But Comparing the 304 headers below between Google and jQuery(MaxCDN):
Google's Expires in one year, the Server type and Alternate-Protocol are proprietary and some experimental stuff, which may make things faster. On the other hand looking at jQuery's headers served, they expire in over 10 years, use keep-alive
, and have an ETAG.
I have done my own synthetic tests and for jQuery I find that jQuery's CDN provided by MaxCDN are faster in terms of network latency and TTFB then the Google hosted ones. That was a long time ago but you can see those tests here: Microsoft CDN for jQuery or Google CDN?
Google's headers: http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
HTTP/1.1 304 Not Modified
Date: Thu, 26 Jun 2014 19:54:52 GMT
Expires: Fri, 26 Jun 2015 19:54:52 GMT
Age: 164637
Server: GFE/2.0
Alternate-Protocol: 80:quic
jQuery's MaxCDN headers: http://code.jquery.com/jquery-1.11.0.min.js
HTTP/1.1 304 Not Modified
Date: Sat, 28 Jun 2014 17:39:58 GMT
Connection: keep-alive
Last-Modified: Wed, 26 Mar 2014 00:56:22 GMT
Vary: Accept-Encoding
ETag: "533225b6-1787d"
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Cache-Control: public
Server: NetDNA-cache/2.2
X-Cache: HIT
I can't find much stats like you're looking for, HTTPArchive is a good place to start but also found
上一篇: 如何使用JAVA将alpha转换为JPEG保存颜色
下一篇: 发现JavaScript CDN命中率