*Summary: *While ServiceWorkers are intended to improve the performance of websites, it's possible for them to be counterproductive to performance. When navigating to a website with a registered ServiceWorker handling fetch events, the browser must first start up the ServiceWorker before the ServiceWorker has an opportunity to provide a response. If the ServiceWorker doesn't provide a response or simply performs a fetch to the initial target URL, the network response time is unnecessarily delayed by the ServiceWorker's start up time.
The idea of "navigation preload" addresses this issue; this API enables the browser to perform a "preload request" for navigations that are potentially handled by a ServiceWorker before executing the ServiceWorker's fetch handler. An associated "preload response" will be available to the ServiceWorker in its fetch handler via a Promise; the ServiceWorker may use the preload response if it doesn't have a response of its own to provide. By making ServiceWorker start up and the preload request concurrent, this API effectively reduces the worst-case network response time as described above from O(ServiceWorker start up time + network request time) to O(max(ServiceWorker start up time, network request time)). Additionally, to allow servers to distinguish between preload requests and non-preload requests, a "Service-Worker-Navigation-Preload" HTTP header will be included with each preload request. Users of the API will have control over this header's value. *Bug:* https://bugzilla.mozilla.org/show_bug.cgi?id=1290958 *Standard:* Discussion: https://github.com/w3c/ServiceWorker/issues/920 Interface: https://w3c.github.io/ServiceWorker/#navigation-preload-manager Integration with "Handle Fetch": https://w3c.github.io/ServiceWorker/#ref-for-service-worker-registration-navigation-preload-enabled-flag%E2%91%A2 *Platform coverage:* All. *Preference:* Enabling this feature will require two preferences: dom.serviceWorkers.navigationPreload.enabled=true (false by default) dom.serviceWorkers.parent_intercept=true (true by default on Nightly; targeting true by default on Beta/Release for Firefox 73) *DevTools bug:* https://bugzilla.mozilla.org/show_bug.cgi?id=1601789 *Other browsers:* Chrome: shipped since Chrome 59 https://www.chromestatus.com/feature/5734842339688448 Safari: considering/public support https://bugs.webkit.org/show_bug.cgi?id=182852 https://github.com/w3c/ServiceWorker/issues/920#issuecomment-236251448 *web-platform-tests:* https://github.com/web-platform-tests/wpt/tree/master/service-workers/service-worker/navigation-preload *Secure contexts:* Yes. *Is this feature enabled by default in sandboxed iframes?* Yes, and it does preserve the invariants in terms of what sandboxed iframes can/can't do. -- Perry Jiang <pe...@mozilla.com> _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform