Skip to content
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

Meteor Auto-compress interfering with Brotli enabled nginx front-end proxy #10377

Closed
georgyberdyshev opened this issue Dec 14, 2018 · 0 comments

Comments

@georgyberdyshev
Copy link
Contributor

georgyberdyshev commented Dec 14, 2018

Hello @benjamn,

the Auto-compress feature of Meteor currently uses gzip compression and is enabled by default.
https://github.com/meteor/meteor/blob/release-1.8.1/packages/webapp/webapp_server.js#L822

When using a front-end proxy, such as nginx, it is not possible to use a different Content-Encoding such as Brotli, because the files are already gzip encoded.

I would like to discuss the possibility to introduce a new environment variable, that allows disabling the Auto-compress feature:
METEOR_DISABLE_AUTO_COMPRESS=1

The implementation is in PR: #10378

1) Running Meteor with --production flag:
gzip is used for Content-Encoding.
01-meteor-gzip

2) Running Meteor with --production flag behind nginx proxy with Brotli enabled:
Mixed Content-Encoding with gzip and br. The gzip encoded files cannot be encoded to Brotli.
02-meteor-nginx-mixed

3) Running patched Meteor with --production flag behind nginx proxy with Brotli enabled:
Only Brotli is used for Content-Encoding. nginx takes care of encoding the uncompressed files to Brotli.
03-meteor-nginx-brotli

Related work on Brotli support
Currently Node.js is working actively on adding Brotli compression to core:
nodejs/node#20458
nodejs/node#18964

There were some discussions in https://github.com/expressjs/compression to support Brotli compression, that were not further pursued.

Brotli browser support: https://caniuse.com/#feat=brotli

Reasoning for environment variable
Adding an environment variable to disable Auto-compress will allow to use Brotli compression through a front-end proxy and provide better compression ratio than gzip.

Some tests with my PR (#10378)

Project gzip brotli br (lvl 11) decrease decrease (br lvl 11)
minimal 16.2 15.2 14 -6.17% -13.58%
bare 65.3 61 55.8 -6.58% -14.55%
full 130 122 112 -6.15% -13.85%
react 106 99.1 90.6 -6.51% -14.53%
angular 255 233 210 -8.63% -17.64%
apollo 385 351 315 -8.83% -18.18%

Note:

Test environment:
Ubuntu 18.04
nginx-1.15.7
brotli: 1.0.3-1ubuntu1.2
ngx_brotli: https://github.com/eustas/ngx_brotli

Thanks, Georgy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants