-
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
Pablo
committed
Oct 4, 2024
1 parent
b5386a2
commit fd388c1
Showing
2 changed files
with
50 additions
and
13 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
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,2 +1,37 @@ | ||
if(!self.define){let e,i={};const n=(n,r)=>(n=new URL(n+".js",r).href,i[n]||new Promise((i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()})).then((()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(r,o)=>{const s=e||("document"in self?document.currentScript.src:"")||location.href;if(i[s])return;let t={};const c=e=>n(e,s),f={module:{uri:s},exports:t,require:c};i[s]=Promise.all(r.map((e=>f[e]||c(e)))).then((e=>(o(...e),t)))}}define(["./workbox-5fc434c9"],(function(e){"use strict";self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()})),e.precacheAndRoute([{url:"images/icono.png",revision:"e134b60d9dc4271a672b6cc947f22bf5"},{url:"images/principal-horizontal.png",revision:"688431d1fd27dead61081ffe700e9593"},{url:"index.html",revision:"40624c4cf34373f498b61ad6be2ec205"},{url:"manifest.json",revision:"22bd873e24ef003621065a36cfe336f8"}],{ignoreURLParametersMatching:[/^utm_/,/^fbclid$/]})})); | ||
//# sourceMappingURL=sw.js.map | ||
const CACHE_NAME = 'cool-cache'; | ||
|
||
// Add whichever assets you want to precache here: | ||
const PRECACHE_ASSETS = [ | ||
'/assets/', | ||
'/src/' | ||
] | ||
|
||
// Listener for the install event - precaches our assets list on service worker install. | ||
self.addEventListener('install', event => { | ||
event.waitUntil((async () => { | ||
const cache = await caches.open(CACHE_NAME); | ||
cache.addAll(PRECACHE_ASSETS); | ||
})()); | ||
}); | ||
|
||
self.addEventListener('activate', event => { | ||
event.waitUntil(self.clients.claim()); | ||
}); | ||
|
||
self.addEventListener('fetch', event => { | ||
event.respondWith(async () => { | ||
const cache = await caches.open(CACHE_NAME); | ||
|
||
// match the request to our cache | ||
const cachedResponse = await cache.match(event.request); | ||
|
||
// check if we got a valid response | ||
if (cachedResponse !== undefined) { | ||
// Cache hit, return the resource | ||
return cachedResponse; | ||
} else { | ||
// Otherwise, go to the network | ||
return fetch(event.request) | ||
}; | ||
}); | ||
}); |