Add cache-first service worker

This commit is contained in:
Ken-Håvard Lieng 2018-11-06 11:13:32 +01:00
parent b2b5f82486
commit ca222ff10d
20 changed files with 672 additions and 181 deletions

14
client/src/js/boot.js Normal file
View file

@ -0,0 +1,14 @@
/* eslint-disable no-underscore-dangle */
// This entrypoint gets inlined in the index page cached by service workers
// and is responsible for fetching the data we would otherwise embed
window.__env__ = fetch('/data', {
credentials: 'same-origin'
}).then(res => {
if (res.ok) {
return res.json();
}
throw new Error(res.statusText);
});