1
0
This repository has been archived on 2026-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
easylogon-demo/public/sw.js
T
2022-05-11 19:49:34 +00:00

31 lines
673 B
JavaScript

let filesToCache =
[
"/",
"/apple-touch-icon.png",
"/icon-512.png",
"/favicon.ico",
"/favicon.svg",
"/banner.png",
"/en",
"/ru"
];
self.addEventListener("install", e =>
{
e.waitUntil(
// Get React bundle files list to cache
fetch("/asset-manifest.json")
.then(response => response.json())
.then(assets => filesToCache.concat(Object.entries(assets.files).map(i => i[1])))
.then(() => caches.open("easylogon-demo"))
.then(cache => cache.addAll(filesToCache))
);
});
self.addEventListener("fetch", event =>
event.respondWith((async () =>
{
let response = await caches.match(event.request);
return response || await fetch(event.request);
})()));