Created
April 28, 2020 16:00
-
-
Save andreasvirkus/c0aa8767eb254a01a0d00b5376017d24 to your computer and use it in GitHub Desktop.
SW for vue-cli with Google's workbox
This file contains hidden or 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
// eslint-disable-next-line no-undef | |
workbox.setConfig({ | |
debug: false | |
}) | |
workbox.core.skipWaiting() | |
workbox.precaching.precacheAndRoute([]) | |
workbox.routing.registerRoute( | |
/\.(?:png|gif|jpg|jpeg|svg)$/, | |
workbox.strategies.staleWhileRevalidate({ | |
cacheName: 'images', | |
plugins: [ | |
new workbox.expiration.Plugin({ | |
maxEntries: 60, | |
maxAgeSeconds: 30 * 24 * 60 * 60 // 30 Days | |
}) | |
] | |
}) | |
) | |
workbox.routing.registerRoute( | |
new RegExp('^https://firestore\\.googleapis\\.com/'), | |
workbox.strategies.networkFirst({ | |
cacheName: 'api' | |
}) | |
) | |
workbox.routing.registerRoute( | |
new RegExp('https://fonts.(?:googleapis|gstatic).com/(.*)'), | |
workbox.strategies.cacheFirst({ | |
cacheName: 'googleapis', | |
plugins: [ | |
new workbox.expiration.Plugin({ | |
maxEntries: 30 | |
}) | |
] | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment