CoolFace
Apppublic

leafspark/typingmind

sourceHugging Faceunknownupdated 2y agoView on Hugging Face
1likes
sw.js25 linesDownload Raw Back to root
1self.addEventListener('install', function (event) {2  console.log('installing service worker');3});4 5self.addEventListener('fetch', function (event) {6  const url = new URL(event.request.url).pathname;7 8  if (url.pathname !== '/') {9    return;10  }11 12  event.respondWith(13    (async function () {14      try {15        var res = await fetch(event.request);16        var cache = await caches.open('cache');17        cache.put(event.request.url, res.clone());18        return res;19      } catch (error) {20        return caches.match(event.request);21      }22    })(),23  );24});25