Reputation: 8874
In production, our static files are served via Akamai (but on our domain), including our service worker.
By default we're caching the service worker but it doesn't seem to always be getting updataed.
What is the right strategy here? Should we set the service worker not to be cached ever and take a hit for every call in the service worker to pull the new service worker each time?
Upvotes: 2
Views: 553
Reputation: 10782
The service worker, if there's a new one, should be updated at least every 24 hours, even if you set 'max-age' to a value greater than 24 hours: https://github.com/slightlyoff/ServiceWorker/blob/master/explainer.md#updating-a-service-worker
The browser will check if there's an update on every page load, but will obey the cache. So you can use 'max-age' to decide how often you want the browser to check for updates.
Upvotes: 3