localStorage versus browser cache (v5)

Revision 5 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://jsperf.com/_css/130824.css";
    
    // 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;
    }
    //console.log('setup')

Teardown


    delete localStorage.test;
    //console.log('teardown')
  

Test runner

Ready to run.

Testing in
TestOps/sec
localStorage
var jquery = localStorage.test;
localStorage.fake = Math.random();
ready
Browser cache
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.