Skip to content

Instantly share code, notes, and snippets.

@ConradIrwin
Created February 3, 2017 22:43
Show Gist options
  • Save ConradIrwin/a634359060cbbde0e90a30e5744aa1a1 to your computer and use it in GitHub Desktop.
Save ConradIrwin/a634359060cbbde0e90a30e5744aa1a1 to your computer and use it in GitHub Desktop.
<script>
function fill(cache) {
let list = [];
for (let i = 0; i < 30000; ++i) {
list.push(cache.put('https://example.com/probably-crash-' + i, new Response('ok')))
}
return Promise.all(list);
}
function read(cache) {
let start = performance.now();
cache.keys().then(keys => {
let end = performance.now();
console.log(end - start);
}).catch(e => {
alert(e)
})
}
function run () {
caches.open("test").then(cache => {
fill(cache).then(() => {
read(cache);
})
})
}
</script>
<div>
Filling <span id="filled">...</span>
<button onclick="run()">Crash!</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment