diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2019-02-18 00:23:20 -0800 |
---|---|---|
committer | Bastien Wirtz <bastien.wirtz@gmail.com> | 2019-02-18 00:23:20 -0800 |
commit | 9baec9aec294656fb632123906b4ac6a712267ba (patch) | |
tree | 0dff55723b3503bfc81f17bfe1d10a8f4298d56f /worker.js | |
parent | e41196e76e6b184fc918fb44adc9af0ff3fdae30 (diff) | |
download | homer-9baec9aec294656fb632123906b4ac6a712267ba.tar.gz homer-9baec9aec294656fb632123906b4ac6a712267ba.tar.zst homer-9baec9aec294656fb632123906b4ac6a712267ba.zip |
Add offline cache + improve layout
Diffstat (limited to 'worker.js')
-rw-r--r-- | worker.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/worker.js b/worker.js new file mode 100644 index 0000000..511c35a --- /dev/null +++ b/worker.js | |||
@@ -0,0 +1,32 @@ | |||
1 | self.addEventListener('install', event => { | ||
2 | event.waitUntil( | ||
3 | caches | ||
4 | .open('homer') | ||
5 | .then(cache => | ||
6 | cache.addAll([ | ||
7 | '/', | ||
8 | '/index.html', | ||
9 | '/config.yml', | ||
10 | '/app.css', | ||
11 | '/app.js', | ||
12 | '/vendors/js-yaml.min.js', | ||
13 | '/assets/logo.png', | ||
14 | 'https://use.fontawesome.com/releases/v5.5.0/css/all.css', | ||
15 | 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css', | ||
16 | 'https://fonts.googleapis.com/css?family=Lato|Raleway', | ||
17 | 'https://cdn.jsdelivr.net/npm/vue@2.6.2/dist/vue.min.js', | ||
18 | ]) | ||
19 | ) | ||
20 | ) | ||
21 | }) | ||
22 | |||
23 | self.addEventListener('fetch', event => { | ||
24 | event.respondWith( | ||
25 | caches.match(event.request).then(response => { | ||
26 | if (response) { | ||
27 | return response; | ||
28 | } | ||
29 | return fetch(event.request); | ||
30 | }) | ||
31 | ); | ||
32 | }); | ||