javascript - Measuring visitor HTTP cache hit ratio for external CDN resources -


my site uses several common cdn hosted resources, bootstrap.css, jquery.js , fontawesome.css. possible information, javascript, site visitors have warm caches these resources in web browsers?

while not answer, interesting insight found when working on problem chrome:

fetching resource cdn deferred call, while fetching item cache seems in fact blocking call, despite being quite fast.
firefox didn't seem exhibit behavior consistently (and didn't bother ie).

to test observation further, built following small fiddle, works reliably me on chrome. please leave comment on own test results if have time.

var testsource = function(href) {    var timelimit = 5;    var l = document.createelement("link");    l.rel = "stylesheet";    l.type = "text/css";    l.href = href;    var s1 = document.createelement("script");    s1.innerhtml = "window.d = new date();";    var s2 = document.createelement("script");    s2.innerhtml = "window.d2 = new date();";    document.head.appendchild(s1);    document.head.appendchild(l);    document.head.appendchild(s2);    window.settimeout(function() {        var p = document.createelement("p");        if (typeof(d2) === "undefined" || d2 - d > timelimit) {          p.innerhtml = "guess cache";        } else {          p.innerhtml = "guess load";        }        p.innerhtml += " (" + href + ")";        document.body.appendchild(p);      },      timelimit * 10);  }    btn.onclick = function() {    testsource(inp.value);  }
<input type="text" id="inp" value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />  <input type="button" id="btn" value="test url" />


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -