Skip to content

Angular 6 - ServiceWorker not requesting gzipped content #24227

Closed

Description

@adnan-kamili

I recently added service worker to my Angular 6.0.3 app. Everything works great.

I observed a slight increased initial load time when app is loaded the first time and to my surprise, the mainxxxx.js file being downloaded was 3.1 MB.

Cloudfront gzips the js files reducing the size of main.xxx.js to around 500KB, but it will only gzip when the client will send the

Accept-Encoding: gzip

request header. The browser was sending this header, but service worker requests don't have this header, which is a big problem because angular build files have very large size.

Is this a bug which will be fixed or service workers don't support gzip which would be a big disappointment.

Chrome 66, MacOS

Activity

  1. added this to the needsTriage milestone on May 31, 2018
  2. gkalpak commented on Jun 1, 2018

    @gkalpak
    Member

    It seems that the SW is stripping headers (and other "metadata") from requests (e.g. here and other places as well). This is intentional (to a degree) to avoid things like credential inclusion in order "to avoid issues with opaque responses".

    We might be over-aggressive here (e.g. it might be OK to preserve (some) headers).
    @alxhub should know more about what kinds of issues we are trying to avoid and if we can be less aggressive.

  3. wachri commented on Mar 22, 2019

    @wachri

    Any updates on that? Working with the service worker is great, but with this "bug" not so production ready....

  4. finnlake commented on Mar 29, 2019

    @finnlake

    I am quite surprised that this feature has not been fixed, almost a year later. Should we start using Workbox instead?

  5. alxhub commented on Jan 23, 2020

    @alxhub
    Member

    Sorry for the inactivity on this issue!

    @gkalpak I think for same-origin requests (do we have a reliable way of detecting these? I don't remember) it makes sense to forward headers like Accept-Encoding.

    Opaque responses are only received if the request was cross-origin.

  6. assigned and unassigned on Jan 23, 2020
  7. 2 remaining items

  8. modified the milestones: needsTriage, Backlog on Oct 1, 2020
  9. tayambamwanza commented on Apr 16, 2021

    @tayambamwanza

    Quite surprised about this, thanks for the work on this, would be amazing, of all the frameworks I've found angular the quickest to setup a good service worker and the consistency really helps.

  10. tinesoft commented on Aug 24, 2022

    @tinesoft

    Any update on this ? @alxhub ? team?
    Would be a great addition to the SW setup..

  11. gkalpak commented on Aug 25, 2022

    @gkalpak
    Member

    @tinesoft, I am working on PR to fix this.

  12. added a commit that references this issue on Sep 6, 2022
    6091786
  13. angular-automatic-lock-bot commented on Oct 7, 2022

    @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.

  14. locked and limited conversation to collaborators on Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functionsarea: service-workerIssues related to the @angular/service-worker packagestate: confirmedtype: bug/fix

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions