{"id":16,"date":"2016-05-26T15:19:49","date_gmt":"2016-05-26T15:19:49","guid":{"rendered":"https:\/\/www.w3.org\/community\/model\/?p=16"},"modified":"2016-05-27T08:38:17","modified_gmt":"2016-05-27T08:38:17","slug":"service-worker-lifecycle-to-improve","status":"publish","type":"post","link":"https:\/\/www.w3.org\/community\/model\/2016\/05\/26\/service-worker-lifecycle-to-improve\/","title":{"rendered":"Service Worker Lifecycle to improve"},"content":{"rendered":"<p>I m testing the possibilities offered by service worker for now and for the future.<\/p>\n<p>I tried to realize a service worker for proxying the clients connection so the browser doesn&#8217;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.<br \/>\nNow it is impossible to do it.<br \/>\nUsing 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<br \/>\n1) ws loses perfomance<br \/>\n2) you can miss the business logic state for every page reload (inter time between reloading phase)<\/p>\n<p>But if i go in another domain , i can&#8217; t notify the user. HTML5 added async events generated by http protocol , but service worker doesn&#8217;t handle them.<\/p>\n<p>Problem in service worker:<br \/>\n1) there is no onstart\/onstop event for managing in intelligent way the connection. Anyway it could be usefull also for other reasons.<br \/>\n2) it is missing a general abstract concept for waking up the service on &#8220;alive objects&#8221; 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&#8217;t add anything to the actual http abilities. I don&#8217;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.<\/p>\n<p>The push notification model seams too much trial for the new challenges of the future.<\/p>\n<p>I thing they could be added to w3c specifications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t make a new connection for every page reload. In &hellip; <a href=\"https:\/\/www.w3.org\/community\/model\/2016\/05\/26\/service-worker-lifecycle-to-improve\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":10806,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"yes","footnotes":""},"categories":[1],"tags":[],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/users\/10806"}],"replies":[{"embeddable":true,"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":5,"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":23,"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/posts\/16\/revisions\/23"}],"wp:attachment":[{"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.w3.org\/community\/model\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}