-
-
Notifications
You must be signed in to change notification settings - Fork 241
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
feat: add brotli support #156
Conversation
Node 10.16.0 (LTS) now has Brotli support too. |
Introducing a dependency that requires pre-compiled binaries and/or a gcc and python 2.7 toolchain just to bring a new feature to a non-active LTS branch that will be dead in 6 months doesn't seem "better" to me. Node 8 is in maintenance, let it remain that way with the existing compression feature set. |
Is there anything missing in this PR to be merged? |
@dougwilson To sum this up, a proper implementation for the options and it's documentation is missing here, correct? Test vise this PR looks already good to me (tests for options would be nice as well as soon as this is implemented). So, regarding the options here some documentation. The only option that looks interchangeable to me is app.use(compression({
filter: shouldCompress,
brotli: {
flush: zlib.constants.BROTLI_OPERATION_PROCESS,
params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 4 },
...
},
zlib: {
flush: zlib.constants.Z_NO_FLUSH,
memLevel: zlib.Z_DEFAULT_MEMLEVEL,
...
}
})) This would require a breaking change, but I would argue that adding this option is a breaking change anyhow if it should be activated by default (which I would prefer) and it would not be to hard to migrate. What is your opinion on this? Am I missing a requirement from the comments in the other PR's/ issues? I would love to get this into the library as it would hopefully have a positive effect on a lot of websites, and the PR already looks solid ❤️ |
@dougwilson struggling to reach 100% coverage with node environments that do not support brotli. |
@dougwilson Can you take another look ? |
Is this still being held up by being not being able to hit 100% coverage? Seems a shame for such a small yet great change which could make a big difference in a large number of sites! |
@KB1RMA I believe the biggest issue is confirming that a major version could be released for this. The existing api needs to change to add brotli support. See here #156 (comment) @dougwilson are you open to releasing a new major version to this module with an updated api that will let people specify separate options for |
@ryhinchey this PR actually breaks out brotli vs gzip settings. But a major version bump does make sense IMO.
Node environments without the new brotli feature are unable to execute a branch of code so the code coverage never reaches 100%. Anyway to work around this for that section of code? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Closed in favor of #194, @patrickmichalina thank you for the initiative. You can continue helping by reviewing #194 so we can launch it. |
createBrotliDecompress
andcreateBrotliCompress
are only available in Node v10.16.0 and above. If the platform you are running supports brotli and the client making a request accepts brotli encoding, this will return brotli encoded responses, otherwise it will fallback as before.Added a config option
brotli
.