-
Conrad Zelck authored
Source: https://www.freecodecamp.org/news/build-a-pwa-from-scratch-with-html-css-and-javascript Inludes pwa caching. Signed-off-by:
Conrad Zelck <git@simpel.cc>
Conrad Zelck authoredSource: https://www.freecodecamp.org/news/build-a-pwa-from-scratch-with-html-css-and-javascript Inludes pwa caching. Signed-off-by:
Conrad Zelck <git@simpel.cc>
serviceWorker.js 583 B
const staticFreqBuddy = "freq-buddy-site-v1"
const assets = [
"/index.php",
"/script.min.js",
"/app.min.js",
"/style.min.css",
"/Simpel_256px_eco.webp",
"/github.svg",
]
self.addEventListener("install", installEvent => {
installEvent.waitUntil(
caches.open(staticFreqBuddy).then(cache => {
cache.addAll(assets)
})
)
})
self.addEventListener("fetch", fetchEvent => {
fetchEvent.respondWith(
caches.match(fetchEvent.request).then(res => {
return res || fetch(fetchEvent.request)
})
)
})