-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
22 lines (17 loc) · 862 Bytes
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const URLs = ['mixed-biscuits', 'bag-o-biscuits', 'biscuit-crumbs', 'biscuit-scrapings', 'biscuit-dust', 'legal-department', 'lawsuits', 'stockists', 'our-history'];
const images = ['img/Peggy-Babcock-Logo.png', 'img/peggy-babcock.jpg', 'img/alligator-park.jpg'];
const icons = ['icons/favicon.ico'];
const dataURLs = URLs.map(url => `data${url}.json`);
const CACHE_VERSION = "v1";
const currentURL = self.location.pathname;
const baseURL = self.location.hostname === 'localhost' ? '/peggybabcock/' : '/';
const ALL_RESOURCES = [...URLs, ...dataURLs, ...icons, ...images].map(url => baseURL + url);
const addResourcesToCache = async (resources) => {
const cache = await caches.open(CACHE_VERSION);
await cache.addAll(resources);
};
self.addEventListener("install", (event) => {
// event.waitUntil(
// addResourcesToCache(ALL_RESOURCES)
// );
});