Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 762
Kevin Burke Avatar asked Feb 21 '12 08:02

Kevin Burke


2 Answers

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.

like image 175
3.3volts Avatar answered Oct 11 '22 22:10

3.3volts


If you have logging on your CDN (we don't seem to?) you could change the CDN url for test runs and also use a pingback url on your server. Over a period of time, compare the ping back url hits and times with your CDN url hits and the unique visitors counts.

You should be able to get an idea about how many unique hits on your cdn url you get vs unique hits you get on your page. The difference should be bots, scrapers and cached or failed loading of resources. Bots you can eliminate, scrapers probably as well, so your %ages should be reflective over a long enough period.

Would this work for you?

We do this on non-cdn resources to see if people are downloading the latest CSS files or not to force a name change only on those IPs that seem to have cached a resource after a change was made to the css file.

like image 25
MyStream Avatar answered Oct 12 '22 00:10

MyStream