← Back to release summary

ServiceWorkerAutoPreload browser mode

Category
Service Worker
Type
New or changed feature
Status
In developer trial (Behind a flag) (Chrome 140)
Intent stage
None

Summary

**ServiceWorkerAutoPreload** is a mode where the browser issues the network request in parallel with the service worker bootstrap. If the fetch handler returns the response with `respondWith()`, the browser consumes the network request result inside the fetch handler. If the fetch handler result is fallback, it passes the network response directly to the browser. ServiceWorkerAutoPreload is an optional browser optimization that changes the existing service worker behavior. Admins can control this feature using an enterprise policy called [ServiceWorkerAutoPreloadEnabled](https://chromeenterprise.google/policies/#ServiceWorkerAutoPreloadEnabled).

Motivation

The ServiceWorker’s fetch handling capability allows developers to intercept and control the resource fetch requests via “fetch” event handler. This enables web apps to be reliable even while offline and delivers faster loading experiences by using its own CacheStorage. However, the cost of starting up a ServiceWorker can be non-negligible. ServiceWorker fetch handlers are invoked during the critical path for navigation and subresource loading. Developers are sometimes using fetch handlers to speed up page loading but the fetch handlers may slow down page loading if the ServiceWorker is not running, or the resource was not cached. In the worst case, it can take up to hundreds of milliseconds to bootstrap the ServiceWorker itself and process fetch event handlers. Fetch handlers are used for various reasons but there are many cases where developers use them with the intention of serving resources faster than the network. To fulfill their intention, this document proposes the introduction of “ServiceWorkerAutoPreload”, a new loading strategy for ServiceWorker.

Standards & signals

Explainers: https://github.com/WICG/service-worker-auto-preload

View on chromestatus.com