Re: [w3c/ServiceWorker] Detecting service worker termination (#1550)

I will look into this and verify if I can find a way to use this as a workaround. 

However, I'm not really sure this is the best way to handle the situation I have in mind, but I could be wrong. 
Say I load some data into the service worker in order to do some complex decision making about routing and managing the cache. If I understand it correctly, in order to not lose the progress made, I have to write the entire state into the database after the response has been returned to the main thread. This seems wasteful to me, as a page load  will require the service worker to process multiple resources, they will have to be written for every request for that page. I don't know when the `FetchEvent.handled` will be executed, but if that happens in between these requests, it will slow down the loading of the page.

With that in mind, a `beforeTerminate` event could be helpful to perform some one-time work to consolidate the state that's in memory, instead of having to do this needlessly after every request. 

Does that makes sense or do you still think your solution is the best way to go?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1550#issuecomment-720640995

Received on Monday, 2 November 2020 18:16:41 UTC