Skip to content

Angular Service Worker should prefetch assets in parallel #39491

@laurentgoudet

Description

@laurentgoudet

🚀 feature request

Relevant Package

This feature request is for @angular/service-worker.

Description

The Angular Service Worker currently prefetches a new version assets one by one, as mentioned in

// Cache all known resources serially. As this reduce proceeds, each Promise waits

// Cache all known resources serially. As this reduce proceeds, each Promise waits
// on the last before starting the fetch/cache operation for the next request. Any
// errors cause fall-through to the final Promise which rejects.

Doing so with a medium/large application that heavily leverage code-splitting in inefficient: in our case we have ~340 assets to prefetch, for a total application size of only 3.0MB, yet upgrades a taking several minutes (sometimes above > 10 minutes) to be ready.

This leads to app upgrades being slower to propagate as they should be, as users have to stick around several minutes within the app for us to be able to switch to (or notify them about) the new version.

Describe the solution you'd like

New versions assets should be prefetched by the Service Worker in parallel. 3MB only takes a second to download on the average broadband connection thanks for h2+ parallelism, and the Angular Service Worker should leverage that.

Describe alternatives you've considered

I am unused if the current behavior was designed on purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: performanceIssues related to performancearea: service-workerIssues related to the @angular/service-worker packagebugfeature: in backlogFeature request for which voting has completed and is now in the backlog

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions