Skip to content

Angular Service Worker should prefetch assets in parallel #39491

Closed as not planned

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.

Activity

  1. added this to the needsTriage milestone on Oct 29, 2020
  2. gkalpak commented on Oct 30, 2020

    @gkalpak
    Member

    I assume this was done to prevent network congestion (@alxhub could confirm).
    I still believe it should be the default behavior (or maybe have a few parallel requests to speed things up a bit). But maybe we could allow specifying the desired parallelism in the asset-group entry in ngsw-config.json.

    This is not a high priority, so not sure when/if we are going to get to it, but if anyone is interested in working on a PR I would be happy to help/review.

  3. added
    featureLabel used to distinguish feature request from other issues
    on Oct 30, 2020
  4. modified the milestones: needsTriage, Backlog on Oct 30, 2020
  5. angular-robot commented on Jun 4, 2021

    @angular-robot
    Contributor

    Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

    Find more details about Angular's feature request process in our documentation.

  6. angular-robot commented on Jun 24, 2021

    @angular-robot
    Contributor

    Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

    We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

    You can find more details about the feature request process in our documentation.

  7. 2 remaining items

  8. added this to the needsTriage milestone on Sep 29, 2022
  9. dylhunn commented on Sep 29, 2022

    @dylhunn
    Contributor

    We consider this degraded performance a bug in service worker. The user should not have to remain on the app for several minutes to get the update.

  10. added
    P4A relatively minor issue that is not relevant to core functions
    on Sep 29, 2022
  11. modified the milestones: needsTriage, Backlog on Sep 29, 2022
  12. jvitor83 commented on Dec 21, 2022

    @jvitor83

    This should be a priority. The prefetch should behave like the browser once it hits the page (downloading the assets at the same time), otherwise the loading will be slower than without service worker.

  13. gkalpak commented on Dec 21, 2022

    @gkalpak
    Member

    FWIW, prefetching does not affect the loading time of the page, since it happens in the background (independently of the page loading process).

  14. jvitor83 commented on Dec 25, 2022

    @jvitor83

    Yes. In my case at the first access i preffer to not show the cached version of the app, but instead a loading screen while it updates and reload (to avoid a eventual breaking change in API make the cached version unusable or gives error).
    In that case, the loading time seems slower than browser because of the downloading assets in sequence, and this issue can drastically improve that performance.

  15. jvitor83 commented on May 13, 2024

    @jvitor83

    Any news about this? The PR is one year old! 🎂

    @gkalpak

  16. JeanMeche commented on Aug 29, 2025

    @JeanMeche
    Member

    With #63364 we've announced that the service-worker package in now in maintenance mode and will not receive feature PRs and feature requests.

    The message is also visible here: https://angular.dev/ecosystem/service-workers

  17. angular-automatic-lock-bot commented on Sep 29, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  18. locked and limited conversation to collaborators on Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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