Issue with cacheDidUpdate plugin in workbox-precaching when other callbacks are also used
See original GitHub issueIn my application, I display a splash screen and wait for complete the installation of the service worker and only then display the content, because the service worker must manipulate the csp token for several tabs for all requests in the API.
On a slow connection, the installation of a service worker can take up to a minute. I would like to keep the user busy with the progress of caching elements at this time.
I read #2406 and wrote a custom plugin for cacheDidUpdate:
export const cacheDidUpdate = async ({ cacheName, request, old Response, new Response, event, state }) => {
const { log } = console;
log('cacheDidUpdate', cacheName, state);
};
I used it in the service worker
addPlugins([cacheDidUpdate ]);
but I didn’t see anything in the console. What am I doing wrong?
Issue Analytics
- State:
- Created 2 years ago
- Comments:37 (20 by maintainers)
Top Results From Across the Web
Using plugins - Chrome Developers
This callback is handy if you need to override or normalize URLs prior to using them to access caches. cachedResponseWillBeUsed : This is...
Read more >workbox changelog
Fixes a bug where the workbox namespace was used before it was defined, ... Plugins implementing the cacheDidUpdate method were not properly bound, ......
Read more >How do I postMessage with custom plugin (cacheDidUpdate)?
I wrote this code but it do nothing in cacheDidUpdate. ... { PrecacheController } = workbox.precaching let { cacheDidUpdate } = workbox.core ...
Read more >workbox-webpack-plugin: Versions - Openbase
As part of this change, workbox-build now uses the TypeScript definitions ... In this proposal, all plugin callbacks will also be passed a...
Read more >Callback plugins - Ansible Documentation
By default, callback plugins control most of the output you see when running the command line programs, but can also be used to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(I’ve updated the code sample to use
event.type === 'install'
instead ofevent instanceof InstallEvent
, since the latter apparently won’t work in Safari, whereInstallEvent
is not defined in theServiceWorkerGlobalScope
.)This approach greatly complicates the life of the developer and disorients beginners - static resources and a
/?source=pwa
router make up the precache list for the application to work offline. You suggest dividing this list and processing its elements in different ways.If I were developing a workbox, I would implement such a contract
And under the hood I would get the integrity attribute for static resources and for static resources from server (with revision) I would do nothing - simply put them as is into manifest assets array.
Thus, the developer would only have to focus on working with the rest of the resources that are not included in the precache list.
P.S: I want to emphasize once again that in this case
/?source=pwa
and/anotherStaticResourceFromServer
are static resources that must be only generated by the product server with its environment and cannot be generated during the build processfor example, ‘/?source=pwa’ route - is an app-shell for the pwa, which is rendered by the server at the request of the client from components that are build and tested during the build process