sw invalidates old caches, maybe - webgbcam - [fork] gameboy webcam
HTML git clone git://src.adamsgaard.dk/webgbcam
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit ef3166ca89920bf10ce86e44e622af41e260cfd8
DIR parent 9ed8259359df59621836f7e97329cc8b9e6622c7
HTML Author: Erin Pinheiro <hello@mynameiser.in>
Date: Mon, 24 Jan 2022 22:55:26 -0300
sw invalidates old caches, maybe
Diffstat:
M sw.js | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
---
DIR diff --git a/sw.js b/sw.js
@@ -1,4 +1,4 @@
-const cacheName = 'webgbcam-v3.2'
+const cacheName = 'webgbcam-v3.1'
self.addEventListener('install', function(e) {
e.waitUntil(
@@ -24,6 +24,23 @@ self.addEventListener('install', function(e) {
);
});
+// this is supposed to invalidate old caches, i think. i don't know. stackoverflow
+self.addEventListener('activate', function(event) {
+ event.waitUntil(
+ caches.keys().then(function(cacheNames) {
+ return Promise.all(
+ cacheNames.filter(function(cacheName) {
+ // Return true if you want to remove this cache,
+ // but remember that caches are shared across
+ // the whole origin
+ }).map(function(cacheName) {
+ return caches.delete(cacheName);
+ })
+ );
+ })
+ );
+});
+
// The fetch handler serves responses for same-origin resources from a cache.
// If no response is found, it populates the runtime cache with the response
// from the network before returning it to the page.