The Wayback Machine - https://web.archive.org/web/20210112091543/https://github.com/expressjs/compression/pull/150
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

feat: support brotli #150

Open
wants to merge 5 commits into
base: master
from
Open

feat: support brotli #150

wants to merge 5 commits into from

Conversation

@clarkdo
Copy link

@clarkdo clarkdo commented Jan 18, 2019

No description provided.

Copy link
Member

@dougwilson dougwilson left a comment

Thank you so much for volunteering to help get this feature a reality! From reviewing the PR, it looks like the following things still need to be done, so I'm listing so you have something concrete to work through:

(1) There is no documentation around this, specifically all the options like chunkSize, level, memLebel, stragety, windowBits, etc. are all using zlib constants and not the Brotli constants. I have not actually looked hard yet, but I assume these constants are not the right ones for Brotli (since the Node.js doc lists different constants) but at worse since all these constants are just integers, setting one of these options may break when br is accepted by the client, since they are going to be passed into createBrotliDecompress with this PR (this needs to be validated / tested).

(2) There are no tests added. This is picked up just by the coverage CI check, since the new line for br in the switch statement is not getting triggered, but there should be at least all the equiv tests for br that there are for the others.

I hope this helps! Thanks for picking this up!

README.md Outdated Show resolved Hide resolved
@clarkdo
Copy link
Author

@clarkdo clarkdo commented Jan 18, 2019

@dougwilson Thank you so much for the quick and detailed review.

For the options, which solution do you think is better ?

  1. Try to match current options into brotli options for keeping consistency, this may be harder and risky since the zlip api are very different between zlib-based and brotli based.
  2. Add a new brotli options field(maybe options.brotli) in options of compression and add doc (the same way as node is doing now)

For the test, since brotli is only supported in node 11.7, can we add it in travis ?

@manniL
Copy link

@manniL manniL commented Feb 19, 2019

Friendly reminder @dougwilson ☺️

Copy link

@cecchi cecchi left a comment

Thanks for working on this @clarkdo!

For what it's worth, in my testing the content negotiation provided by accepts (which uses negotiator under the hood) will choose gzip over br for most popular browsers. There's an issue tracking that behavior here: jshttp/negotiator#49

Working off of your branch I was able to get Brotli working end-to-end by swapping out the content negotiation from "accepts" to "accept": https://www.npmjs.com/package/accept, and fixing a couple typos.

I'm happy to contribute those changes if we want to prefer br over gzip. The changelist is visible here: deal#1

index.js Outdated Show resolved Hide resolved
@svewag
Copy link

@svewag svewag commented Apr 24, 2019

Hi there 👋

I would really like to serve my static files with brotli. So are there any plans when this might be merged or can I help out somewhere?

Greetings Sven

@Saiv46
Copy link

@Saiv46 Saiv46 commented Nov 8, 2020

Any progress?

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

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.