Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
async function getFromNetwork(req) {
const cache = await caches.open('data');
try {
const res = await fetch(req);
cache.put(req, res.clone());
return res;
} catch (e) {
const res = await cache.match(req);
return res || getFallback(req);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.