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

Allow tuning of Brotli compression level #106

Closed
iansltx opened this issue Mar 31, 2020 · 3 comments
Closed

Allow tuning of Brotli compression level #106

iansltx opened this issue Mar 31, 2020 · 3 comments

Comments

@iansltx
Copy link

iansltx commented Mar 31, 2020

🚀 Feature Proposal

Add ability to specify brotli compression level, preferably globally

Motivation

Brotli is great for compressing static assets, where you can amortize the cost of compression across multiple responses, however in its default configuration it takes an extremely (multiple orders of magnitude vs. gzip) long time to compress data, making it a hard sell for dynamic content, particularly compared to near-instant compression provided by gzip/deflate. Given that in e.g. NestJS the compression phase happens after responses are pulled from cache on the Nest side, even aggressively server-side cached responses can't amortize exprensive compression operations across multiple requests.

Turning down the compression level on brotli may allow for acceptable compression times while still maintaining a compression ratio superior to gzip/deflate.

Example

When specifying brotli as a compression method, add a level parameter to the object. I'm guessing that the default is maximum compression (11?), and for BC reasons it'd be reasonable to keep that default if the level parameter wasn't provided.

@mcollina
Copy link
Member

Would you like to send a PR?

@iansltx
Copy link
Author

iansltx commented Mar 31, 2020

From a quick look at the code, the solution didn't seem obvious, but if I wind up with time to circle back to this (we're going with gzip/deflate now) I'll try for a PR if one hasn't yet been built.

SystemDisc added a commit to SystemDisc/fastify-compress that referenced this issue May 29, 2020
mcollina pushed a commit that referenced this issue Jun 26, 2020
* Support passing zlibOptions and brotliOptions

#106

* Update tests, types, and docs

Co-authored-by: Blake Sager <blake.sager@activeprospect.com>
@delvedor
Copy link
Member

Closed in #113.

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

No branches or pull requests

3 participants