Is there a way to match wildcard URLs on a serviceWorker
's install
event?
I'd like to be able to match something like *.bundle.js
.
self.addEventListener('install', event => {
event.waitUntil(
caches.open(latest.cache).then(cache => {
return cache.addAll([
'/',
'*.bundle.js'
])
})
)
})
match() The match() method of the Cache interface returns a Promise that resolves to the Response associated with the first matching request in the Cache object. If no match is found, the Promise resolves to undefined .
Caching unnecessary resources wastes bandwidth and storage space and could cause your app to serve unintended outdated resources. You don't need to cache all the assets at once, you can cache assets many times during the lifecycle of your PWA, such as: On installation of the service worker. After the first page load.
A PWA that goes unused for a 'few weeks' (we think it is 2 weeks) the iOS device deletes or purges the stored values. That is unless it has been added to the homescreen. Not exactly the most user friendly policy and definitely not favorable to a business using service workers to provide better user experience.
I don't think that's possible since you're not caching strings or urls, but requests.
There is a thing from Google that might be of use, the sw-precache module. This can generate a service worker through Gulp or the commandline. It works alongside the service worker toolbox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With