7

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.)

mahemoff
  • 44,526
  • 36
  • 160
  • 222
  • It would be nice if one day we could just add multiple equivalent origins for a file and the browser would check if any of those origins is already cached and only make a request otherwise. – gabrielmaldi May 15 '14 at 14:35
  • Agree and related would be good if we could include a per-script hash value browsers could check against to be sure it's the script we wanted. – mahemoff May 15 '14 at 14:37
  • As an additional check following the URL match, for us paranoids, nice :) – gabrielmaldi May 15 '14 at 15:07
  • 1
    I can put together a BigQuery against the HTTP Archive. Can you provide with a list of CDN domains? I seldom use CDNs, so other than jQuery and Google I don't know what else to include. – Nacho Coloma May 19 '14 at 10:13
  • Good idea. I can't seem to find a big compilation, but the big ones are CDNJS http://cdnjs.com/ MS http://www.asp.net/ajaxlibrary/cdn.ashx Google https://developers.google.com/speed/libraries/devguide JSDelivr http://www.jsdelivr.com/. I would just start by picking for example jQuery 2.0.0 from each of them. – mahemoff May 19 '14 at 10:23
  • You're asking which CDN to use. If that's not asking for a *recommendation*... Also asking for data on hit rates is asking for *off-site resources*. Besides which CDN would be best for your website depends on what visitors you have and what websites they have visited before. – Cristian Ciupitu Jun 28 '14 at 19:00
  • I didn't ask which CDN to use. Please re-read the question if you're under that impression. – mahemoff Jun 28 '14 at 19:32
  • @mahemoff, ok, it's not exactly asking for a recommendation, but pretty close. Anyway your question is as relevant to programming as buying a book from either Amazon or eBay is to writing. So it's off-topic. And there's also the off-site resource issue, too. Nevertheless, your question _might_ be appropriate for the [**Webmasters Stack Exchange**](http://webmasters.stackexchange.com/). I suggest trying there after reading the rules of course. – Cristian Ciupitu Jun 29 '14 at 16:04

1 Answers1

3

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

Community
  • 1
  • 1
Anthony Hatzopoulos
  • 10,437
  • 2
  • 40
  • 57