draft PWA

This commit is contained in:
2023-08-16 16:02:20 +03:00
parent 0b0c69b261
commit f5c545ed42
18 changed files with 219 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
const staticExamplePWA = 'example-pwa-site-v1';
const assets = [
'/',
'/index.html',
'/styles.css',
'/app.js',
'/images/Bear.png',
'/images/DeusEx.png',
'/images/Face.png',
'/images/Tony_Stark.jpg',
];
self.addEventListener('install', (installEvent) => {
installEvent.waitUntil(
caches.open(staticExamplePWA).then((cache) => {
cache.addAll(assets);
}),
);
});
self.addEventListener('fetch', (fetchEvent) => {
fetchEvent.respondWith(
caches.match(fetchEvent.request).then((res) => {
return res || fetch(fetchEvent.request);
}),
);
});