You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
// CREDITS: https://github.com/umluizlima/flask-pwa/blob/master/app/static/sw.js
|
|
// File Created by [Check Commits for Name]
|
|
|
|
console.log('Hello from sw.js');
|
|
|
|
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.2.0/workbox-sw.js');
|
|
|
|
if (workbox) {
|
|
console.log(`Yay! Workbox is loaded 🎉`);
|
|
|
|
workbox.precaching.precacheAndRoute([
|
|
{
|
|
"url": "/login",
|
|
"revision": "1"
|
|
}
|
|
]);
|
|
|
|
workbox.routing.registerRoute(
|
|
/\.(?:js|css)$/,
|
|
workbox.strategies.staleWhileRevalidate({
|
|
cacheName: 'static-resources',
|
|
}),
|
|
);
|
|
|
|
workbox.routing.registerRoute(
|
|
/\.(?:png|gif|jpg|jpeg|svg)$/,
|
|
workbox.strategies.cacheFirst({
|
|
cacheName: 'images',
|
|
plugins: [
|
|
new workbox.expiration.Plugin({
|
|
maxEntries: 60,
|
|
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
|
|
}),
|
|
],
|
|
}),
|
|
);
|
|
|
|
workbox.routing.registerRoute(
|
|
new RegExp('https://fonts.(?:googleapis|gstatic).com/(.*)'),
|
|
workbox.strategies.cacheFirst({
|
|
cacheName: 'googleapis',
|
|
plugins: [
|
|
new workbox.expiration.Plugin({
|
|
maxEntries: 30,
|
|
}),
|
|
],
|
|
}),
|
|
);
|
|
} else {
|
|
console.log(`Boo! Workbox didn't load 😬`);
|
|
}
|