Skip to toolbar

Community & Business Groups

Service Worker Lifecycle to improve

I m testing the possibilities offered by service worker for now and for the future.

I tried to realize a service worker for proxying the clients connection so the browser doesn’t make a new connection for every page reload. In addition i want the connection stay alive during the navigation so if the websocket sent a event , i can notify the event to the user.
Now it is impossible to do it.
Using shared worker now at maximum you can proxy a connection until user has a page opened in that domain. Considering that it is the minimum to do , because else
1) ws loses perfomance
2) you can miss the business logic state for every page reload (inter time between reloading phase)

But if i go in another domain , i can’ t notify the user. HTML5 added async events generated by http protocol , but service worker doesn’t handle them.

Problem in service worker:
1) there is no onstart/onstop event for managing in intelligent way the connection. Anyway it could be usefull also for other reasons.
2) it is missing a general abstract concept for waking up the service on “alive objects” as websocket,server sent messages. On message event it might wake up the service as now it does it for pushmanager. Pushmanager use a protocol that don’t add anything to the actual http abilities. I don’t understand for what reason to add another protocol. I might registerAliveObject(ws) in serviceWorkerScope and the browser manages the wakeing up on message. Conceptually it is more general and permits to do all what a developer can imagine. Service worker has short life as now.

The push notification model seams too much trial for the new challenges of the future.

I thing they could be added to w3c specifications.

Leave a Reply

Your email address will not be published. Required fields are marked *

Before you comment here, note that this forum is moderated and your IP address is sent to Akismet, the plugin we use to mitigate spam comments.

*