-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00d3806
commit 035d644
Showing
1 changed file
with
23 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
const CACHE_NAME = "shroomlife-1.3.0"; | ||
const CACHE_NAME = 'shroomlife-1.3.0' | ||
|
||
self.addEventListener("install", (event) => { | ||
self.addEventListener('install', (event) => { | ||
event.waitUntil( | ||
caches.open(CACHE_NAME).then((cache) => { | ||
const urlsToCache = ["/favicon.ico"]; | ||
return cache.addAll(urlsToCache); | ||
const urlsToCache = ['/favicon.ico'] | ||
return cache.addAll(urlsToCache) | ||
}) | ||
); | ||
}); | ||
) | ||
}) | ||
|
||
self.addEventListener("activate", (event) => { | ||
self.addEventListener('activate', (event) => { | ||
event.waitUntil( | ||
caches.keys().then((cacheNames) => { | ||
return Promise.all( | ||
cacheNames.map((cacheName) => { | ||
if (cacheName !== CACHE_NAME) { | ||
return caches.delete(cacheName); | ||
return caches.delete(cacheName) | ||
} | ||
}) | ||
); | ||
) | ||
}) | ||
); | ||
}); | ||
) | ||
}) | ||
|
||
self.addEventListener("fetch", (event) => { | ||
self.addEventListener('fetch', (event) => { | ||
event.respondWith( | ||
caches.match(event.request).then((response) => { | ||
if (response) { | ||
return response; | ||
return response | ||
} | ||
|
||
var fetchRequest = event.request.clone(); | ||
const fetchRequest = event.request.clone() | ||
|
||
return fetch(fetchRequest).then((response) => { | ||
if (!response || response.status !== 200 || response.type !== "basic") { | ||
return response; | ||
if (!response || response.status !== 200 || response.type !== 'basic') { | ||
return response | ||
} | ||
|
||
var responseToCache = response.clone(); | ||
const responseToCache = response.clone() | ||
|
||
caches.open(CACHE_NAME).then((cache) => { | ||
cache.put(event.request, responseToCache); | ||
}); | ||
cache.put(event.request, responseToCache) | ||
}) | ||
|
||
return response; | ||
}); | ||
return response | ||
}) | ||
}) | ||
); | ||
}); | ||
) | ||
}) |