I am working on a project that uses create-react-app and workbox for the Service Worker in order to support offline mode. I'm also using workbox-precaching module to precache resources once the Service Worker is installed.
According to the workbox-precaching documentation, when the page loads, it automatically detects if there is a new version available and precaches it:
When a user later revisits your web app and you have a new service worker with different precached assets, workbox-precaching will look at the new list and determine which assets are completely new and which of the existing assets need updating, based on their revisioning. Any new assets, or updating revisions, will be added to the cache during the new service worker's install event.
This is a good feature to ensure the user has always the latest resources available in the cache, but I need to somehow 'pause' this behavior (e.g. when the user is not logged in), so even if the user reload the page, it will work as if it were offline using the cached assets until a certain condition authorizes the Service Worker to check again for updates and fetches the new resources if necessary.
Is there any way to do this without removing the precaching module and managing the cache on my own?
Thanks!