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
brotli support in gzip plugin #1557
Conversation
Added the requirements here:
|
Having one plugin for multiple compression algorithms is fine with me. However, I'm not a big fun of adding it with "else if" statements, though we already did that for deflate. It looks like ifdef things and it's not so easy to read. I think it should have an abstract parent class for all the algorithms and each algorithms should be implemented as subclasses. |
I will take a closer look in the coming days. |
I need to read this some more, but it feels like we need a configuration option here as well. |
@bryancall @zwoop I am working on a enhancement to force brotli compression even if content-encoding header is present. |
plugins/gzip/gzip.cc
Outdated
@@ -95,18 +104,29 @@ gzip_data_alloc(int compression_type) | |||
} | |||
} | |||
|
|||
if(compression_type == COMPRESSION_TYPE_BROTLI) { | |||
debug("gzip-transform: brotli compression. Create Brotli Encoder Instance."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clang-format over the change. gmake clang-format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
It looks like brotli is on by default? It would be nice to have an option on what types of compression algorithms that you want to enable. |
@bryancall Yes the default behavior is br. Are you suggesting that the option should dictate normalizing the AE? What will be the behavior when both gzip and br are selected? |
@myraid The configuration option would be something like: It would really be nice to enable Brotli on certain content types (e.g. text/javascript) that are static and not on types that would be more dynamic (e.g. text/html). Unfortunately the configuration doesn't easily lend itself to this. |
plugins/gzip/gzip.cc
Outdated
error("brotli-transform: ERROR: output lengths don't match (%d, %ld)", data->downstream_length, data->bstrm.total_out); | ||
} | ||
debug("brotli-transform: Finished brotli"); | ||
// gzip_log_ratio(data->bstrm.total_in, data->downstream_length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we still do similar logging brotli? Or at least some useful data
My feedbacks
The pros is that
The cons is that
Any thoughts? @zwoop @bryancall @myriad ? |
See also ##776. |
Added the supported-algorithms cofiguration. compression will be triggered for response based on Accept-Encoding and supported algorithms (brotli is checked before gzip). A transform is not even created if the there is no intersect between Accept-Encoding and supported algorithms. Caching scenarios. We only cache 2 copies
@shukitchan Accept-Encoding header will suffice. This is similar to what you have suggested, but without an additional header. you agree? |
@myraid your description seems to be good. i will spend some times tomorrow to review the code. meanwhile, pls update this as well |
two more points
P.S. I think enforce-brotli and supported-algorithms should be independent of each other. |
@shukitchan My Comments inline
|
wouldn't it be easier if "enforce-brotli" will override the "Accept-Encoding" to "br"? Another concern @bryancall made in an email with us is whether we should only do this brotli encoding transform only if response is cacheable. I wonder whether we should do it in this PR or have a custom version internally instead. |
Yes we could enforce brotli encoding by overriding the Accept-Encoding to "br" if we are OK with origin responding with plain text. Infact this is cleaner approach. May be you are thinking of a separate unzip plugin. Ether ways I am fine. Infact we can keep this plugin clean without adding gunzip functionality. @shukitchan I will work the changes you suggested. |
@shukitchan @bryancall can you guys review. |
@shukitchan @bryancall can you review the new code. |
[approve ci] |
it looks good to me. |
AU check successful! https://ci.trafficserver.apache.org/job/autest-github/91/ |
AU check failed! https://ci.trafficserver.apache.org/job/autest-github/124/ |
Linux build failed! https://ci.trafficserver.apache.org/job/linux-github/1714/ |
clang format failed! https://ci.trafficserver.apache.org/job/clang-format-github/127/ |
RAT check failed! https://ci.trafficserver.apache.org/job/RAT-github/141/ |
FreeBSD11 build failed! https://ci.trafficserver.apache.org/job/freebsd-github/1823/ |
clang-analyzer build failed! https://ci.trafficserver.apache.org/job/clang-analyzer-github/385/ |
Intel CC build failed! https://ci.trafficserver.apache.org/job/icc-github/253/ |
[approve ci] |
Linux build failed! https://ci.trafficserver.apache.org/job/linux-github/1715/ |
clang format failed! https://ci.trafficserver.apache.org/job/clang-format-github/128/ |
RAT check failed! https://ci.trafficserver.apache.org/job/RAT-github/142/ |
FreeBSD11 build failed! https://ci.trafficserver.apache.org/job/freebsd-github/1824/ |
clang-analyzer build failed! https://ci.trafficserver.apache.org/job/clang-analyzer-github/386/ |
Intel CC build failed! https://ci.trafficserver.apache.org/job/icc-github/254/ |
AU check failed! https://ci.trafficserver.apache.org/job/autest-github/125/ |
[approve ci] |
RAT check successful! https://ci.trafficserver.apache.org/job/RAT-github/144/ |
clang format successful! https://ci.trafficserver.apache.org/job/clang-format-github/130/ |
AU check successful! https://ci.trafficserver.apache.org/job/autest-github/127/ |
Linux build successful! https://ci.trafficserver.apache.org/job/linux-github/1717/ |
FreeBSD11 build successful! https://ci.trafficserver.apache.org/job/freebsd-github/1826/ |
Intel CC build successful! https://ci.trafficserver.apache.org/job/icc-github/256/ |
clang-analyzer build successful! https://ci.trafficserver.apache.org/job/clang-analyzer-github/388/ |
The requirements are outlined in
#1555
For brotli to work the "proxy.config.http.normalize_ae_gzip" configuration should be set to '0'
Should we control this flag manually or through the gzip plugin?
@bryancall @shukitchan can you review.