{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/ServiceWorker/issues/920","repository_url":"https://api.github.com/repos/w3c/ServiceWorker","labels_url":"https://api.github.com/repos/w3c/ServiceWorker/issues/920/labels{/name}","comments_url":"https://api.github.com/repos/w3c/ServiceWorker/issues/920/comments","events_url":"https://api.github.com/repos/w3c/ServiceWorker/issues/920/events","html_url":"https://github.com/w3c/ServiceWorker/issues/920","id":162585129,"number":920,"title":"Making a concurrent request for navigations","user":{"login":"slightlyoff","id":97331,"avatar_url":"https://avatars.githubusercontent.com/u/97331?v=3","gravatar_id":"","url":"https://api.github.com/users/slightlyoff","html_url":"https://github.com/slightlyoff","followers_url":"https://api.github.com/users/slightlyoff/followers","following_url":"https://api.github.com/users/slightlyoff/following{/other_user}","gists_url":"https://api.github.com/users/slightlyoff/gists{/gist_id}","starred_url":"https://api.github.com/users/slightlyoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slightlyoff/subscriptions","organizations_url":"https://api.github.com/users/slightlyoff/orgs","repos_url":"https://api.github.com/users/slightlyoff/repos","events_url":"https://api.github.com/users/slightlyoff/events{/privacy}","received_events_url":"https://api.github.com/users/slightlyoff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jakearchibald","id":93594,"avatar_url":"https://avatars.githubusercontent.com/u/93594?v=3","gravatar_id":"","url":"https://api.github.com/users/jakearchibald","html_url":"https://github.com/jakearchibald","followers_url":"https://api.github.com/users/jakearchibald/followers","following_url":"https://api.github.com/users/jakearchibald/following{/other_user}","gists_url":"https://api.github.com/users/jakearchibald/gists{/gist_id}","starred_url":"https://api.github.com/users/jakearchibald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakearchibald/subscriptions","organizations_url":"https://api.github.com/users/jakearchibald/orgs","repos_url":"https://api.github.com/users/jakearchibald/repos","events_url":"https://api.github.com/users/jakearchibald/events{/privacy}","received_events_url":"https://api.github.com/users/jakearchibald/received_events","type":"User","site_admin":false},"assignees":[{"login":"jakearchibald","id":93594,"avatar_url":"https://avatars.githubusercontent.com/u/93594?v=3","gravatar_id":"","url":"https://api.github.com/users/jakearchibald","html_url":"https://github.com/jakearchibald","followers_url":"https://api.github.com/users/jakearchibald/followers","following_url":"https://api.github.com/users/jakearchibald/following{/other_user}","gists_url":"https://api.github.com/users/jakearchibald/gists{/gist_id}","starred_url":"https://api.github.com/users/jakearchibald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakearchibald/subscriptions","organizations_url":"https://api.github.com/users/jakearchibald/orgs","repos_url":"https://api.github.com/users/jakearchibald/repos","events_url":"https://api.github.com/users/jakearchibald/events{/privacy}","received_events_url":"https://api.github.com/users/jakearchibald/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/w3c/ServiceWorker/milestones/3","html_url":"https://github.com/w3c/ServiceWorker/milestones/Version%202","labels_url":"https://api.github.com/repos/w3c/ServiceWorker/milestones/3/labels","id":825216,"number":3,"title":"Version 2","description":null,"creator":{"login":"KenjiBaheux","id":6354698,"avatar_url":"https://avatars.githubusercontent.com/u/6354698?v=3","gravatar_id":"","url":"https://api.github.com/users/KenjiBaheux","html_url":"https://github.com/KenjiBaheux","followers_url":"https://api.github.com/users/KenjiBaheux/followers","following_url":"https://api.github.com/users/KenjiBaheux/following{/other_user}","gists_url":"https://api.github.com/users/KenjiBaheux/gists{/gist_id}","starred_url":"https://api.github.com/users/KenjiBaheux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KenjiBaheux/subscriptions","organizations_url":"https://api.github.com/users/KenjiBaheux/orgs","repos_url":"https://api.github.com/users/KenjiBaheux/repos","events_url":"https://api.github.com/users/KenjiBaheux/events{/privacy}","received_events_url":"https://api.github.com/users/KenjiBaheux/received_events","type":"User","site_admin":false},"open_issues":48,"closed_issues":29,"state":"open","created_at":"2014-10-14T08:25:32Z","updated_at":"2016-10-06T14:13:09Z","due_on":null,"closed_at":null},"comments":119,"created_at":"2016-06-28T01:46:24Z","updated_at":"2016-10-28T16:12:55Z","closed_at":null,"body":"Apologies in advance for the length of this issue.\r\n\r\nA few weeks ago I was discussing the topic of the upcoming [\"PlzNavigate\" feature](https://bugs.chromium.org/p/chromium/issues/detail?id=368813) with @naskooskov, @n8schloss, and @bmaurer.\r\n\r\nThe TL;DR of PlzNavigate is that navigation actions in Chromium will not be handled as they currently are -- sending them through a Renderer process which then routes them to the Browser process for eventual dispatch by the network stack -- and will instead be immediately routed to the Browser-side network stack, improving time-to-navigation in the common (non-SW-controlled) case. This is beneficial in the PlzNavigate world which is much more aggressively multi-process oriented. Saving the time to create processes is a big win, particularly on Android which \"features\" particularly slow native process creation.\r\n\r\nIn Chromium (and one assumes similarly architected browsers), this means that PlzNavigate-style request optimisation runs afoul of Service Worker handling of these requests. This isn't particularly satisfying as the SW may indeed choose to make a request for the top-level resource from the network. Indeed, waiting to issue these requests on Service Worker startup is being reported by large sites as a regression in the 10s or even hundred+ millisecond range. This is notable on sites which do not handle fetches for top-level documents but only want to use SWs for caching.\r\n\r\nWhat if we could enable PlzNavigate _and_ remove the hit generated by SW startup?\r\n\r\nThe idea in the following proposal is to allow a style of declarative navigation request decoration for these \"preflight\" navigation requests, allowing the Service Worker to use (or discard) the response. If no decoration is added and the site's SW decides to handle the request directly (e.g. with a `e.respondWith(fetch(e.request))`), nothing should break. Similarly, it's a goal to avoid sending the results of the \"preflight\" request to the document without the Service Worker's involvement.\r\n\r\nTo accomplish this, the proposal we sketched out on the whiteboard was to allow the `onfetch` event that corresponds to the navigation to have access to the original (preflight) response. To enable a savvy server-side to repurpose this preflight navigation to, e.g., send up-to-date data in a different format than HTML (imagine JSON or similar), we'd also allow the Service Worker to register a header to pass along with the preflight'd navigation request. All together, the strawman looks roughly like:\r\n\r\n```js\r\nself.onactivate = (e) => {\r\n  // If unset, preflight requests are sent without special marking\r\n  e.setPreflightHeader(\"X-Site-Specific-Header\", \"thinger\");\r\n\r\n  // ...\r\n}\r\n\r\nself.onfetch = (e) => {\r\n  if (e.preflightResponse) {\r\n    // This is a navigation fetch which has already been issued.\r\n    // If the `preflightResponse` isn't used, then everything proceeds as\r\n    // if it hadn't been sent in the first place.\r\n  }\r\n}\r\n```\r\n\r\nObviously the names are bike-sheddable. The goal however isn't to be super declarative about deciding what \"routes\" are handled in which style. Instead, it's to allow the maximum of flexibility for cooperating servers and clients to eliminate SW startup latency.\r\n\r\nThoughts?\r\n\r\n/cc @jakearchibald @wanderview @jungkees @mkruisselbrink "},"comment":{"url":"https://api.github.com/repos/w3c/ServiceWorker/issues/comments/256962443","html_url":"https://github.com/w3c/ServiceWorker/issues/920#issuecomment-256962443","issue_url":"https://api.github.com/repos/w3c/ServiceWorker/issues/920","id":256962443,"user":{"login":"wanderview","id":1256526,"avatar_url":"https://avatars.githubusercontent.com/u/1256526?v=3","gravatar_id":"","url":"https://api.github.com/users/wanderview","html_url":"https://github.com/wanderview","followers_url":"https://api.github.com/users/wanderview/followers","following_url":"https://api.github.com/users/wanderview/following{/other_user}","gists_url":"https://api.github.com/users/wanderview/gists{/gist_id}","starred_url":"https://api.github.com/users/wanderview/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wanderview/subscriptions","organizations_url":"https://api.github.com/users/wanderview/orgs","repos_url":"https://api.github.com/users/wanderview/repos","events_url":"https://api.github.com/users/wanderview/events{/privacy}","received_events_url":"https://api.github.com/users/wanderview/received_events","type":"User","site_admin":false},"created_at":"2016-10-28T16:12:55Z","updated_at":"2016-10-28T16:12:55Z","body":"@jakearchibald Are we sure we will never want this for non-navigations?  Should it just be called `preload` instead of `navigationPreload`?"}}
{"actor":{"display_login":"wanderview"}}