localStorage versus browser cache (v9)

Revision 9 of this benchmark created on


Description

Is it quicker to retrieve a javascript file from localStorage than it is to let the browser fetch a cached copy from its own cache?

Setup

// A random URL from a CORS enabled data source
    var url = "http://localhost:8080/bower_components/underscore/underscore-min.js";
    
    // This can be synchronous for testing purposes
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url, false);
    xhr.send();
    if (xhr.status === 200) {
      localStorage.test = xhr.responseText;
    }

Teardown


    delete localStorage.test;
  

Test runner

Ready to run.

Testing in
TestOps/sec
localStorage
var jquery = localStorage.test;
ready
Browser cache
// async test
xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
xhr.send();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.