Search code examples
javascriptjquerycdn

Find jQuery cache hit/miss from CDN


If you include jQuery from a CDN, is there a way to determine whether a user fetched the content from the CDN or retrieved it from their cache?

Obviously a cache hit doesn't make an HTTP request, but could you test that and report Javascript back to your own server with the data?


Solution

  • Why not just use CHARLES or a similar debugging proxy to determine loading speed?

    If you want to know the speed from a client's perspective from multiple locations, use http://www.webpagetest.org/ with two differing versions of your website (one with CDN, one with self-hosted static location) and compare the loading speeds. Personally, unless you have a lot of custom javascript code, it makes sense to use a CDN for jQuery, especially since lots of sites use the Google Libraries API for jQuery.