-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular 6 - ServiceWorker not requesting gzipped content #24227
Comments
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). |
Any updates on that? Working with the service worker is great, but with this "bug" not so production ready.... |
I am quite surprised that this feature has not been fixed, almost a year later. Should we start using Workbox instead? |
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 Opaque responses are only received if the request was cross-origin. |
Maybe related with this we are experimenting encoding changes by the ServiceWorker on our Content-disposition header (the one that contains the filename) |
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. |
Any update on this ? @alxhub ? team? |
@tinesoft, I am working on PR to fix this. |
Previously, when requesting non-cached asset resources from the network, the ServiceWorker would stip off all request metadata (including headers). This was done in order to avoid issues with opaque responses, but it turned out to be overly aggressive, breaking/worsening legit usecases (such as requesting compressed responses). This commit fixes this by preserving the headers of such requests. For reference, Workbox passes the orignal request as is. (See for example the [NetworkFirst][1] strategy). NOTE: Data requests (i.e. requests for URLs that belong to a data-group) are not affected by this. They already use the original resource as is. [1]: https://github.com/GoogleChrome/workbox/blob/95f97a207fd51efb3f8a653f6e3e58224183a778/packages/workbox-strategies/src/NetworkFirst.ts#L90 Fixes angular#24227
Previously, when requesting non-cached asset resources from the network, the ServiceWorker would strip off all request metadata (including headers). This was done in order to avoid issues with opaque responses, but it turned out to be overly aggressive, breaking/worsening legit usecases (such as requesting compressed data). This commit fixes this by preserving the headers of such requests. For reference, Workbox passes the original request as is. (See for example the [NetworkFirst][1] strategy). NOTE: Data requests (i.e. requests for URLs that belong to a data-group) are not affected by this. They already use the original resource as is. [1]: https://github.com/GoogleChrome/workbox/blob/95f97a207fd51efb3f8a653f6e3e58224183a778/packages/workbox-strategies/src/NetworkFirst.ts#L90 Fixes angular#24227
Previously, when requesting non-cached asset resources from the network, the ServiceWorker would strip off all request metadata (including headers). This was done in order to avoid issues with opaque responses, but it turned out to be overly aggressive, breaking/worsening legit usecases (such as requesting compressed data). This commit fixes this by preserving the headers of such requests. For reference, Workbox passes the original request as is. (See for example the [NetworkFirst][1] strategy). > **Note** > Data requests (i.e. requests for URLs that belong to a data-group) are not affected by this. They already use the original resource as is. [1]: https://github.com/GoogleChrome/workbox/blob/95f97a207fd51efb3f8a653f6e3e58224183a778/packages/workbox-strategies/src/NetworkFirst.ts#L90 Fixes angular#24227
Previously, when requesting non-cached asset resources from the network, the ServiceWorker would strip off all request metadata (including headers). This was done in order to avoid issues with opaque responses, but it turned out to be overly aggressive, breaking/worsening legit usecases (such as requesting compressed data). This commit fixes this by preserving the headers of such requests. For reference, Workbox passes the original request as is. (See for example the [NetworkFirst][1] strategy). > **Note** > Data requests (i.e. requests for URLs that belong to a data-group) are not affected by this. They already use the original resource as is. [1]: https://github.com/GoogleChrome/workbox/blob/95f97a207fd51efb3f8a653f6e3e58224183a778/packages/workbox-strategies/src/NetworkFirst.ts#L90 Fixes #24227 PR Close #47260
…47260) Previously, when requesting non-cached asset resources from the network, the ServiceWorker would strip off all request metadata (including headers). This was done in order to avoid issues with opaque responses, but it turned out to be overly aggressive, breaking/worsening legit usecases (such as requesting compressed data). This commit fixes this by preserving the headers of such requests. For reference, Workbox passes the original request as is. (See for example the [NetworkFirst][1] strategy). > **Note** > Data requests (i.e. requests for URLs that belong to a data-group) are not affected by this. They already use the original resource as is. [1]: https://github.com/GoogleChrome/workbox/blob/95f97a207fd51efb3f8a653f6e3e58224183a778/packages/workbox-strategies/src/NetworkFirst.ts#L90 Fixes angular#24227 PR Close angular#47260
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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
The text was updated successfully, but these errors were encountered: