Skip to content

Variable compression level - #58

Open
bartebor wants to merge 1 commit into
google:masterfrom
bartebor:var_comp_level2
Open

Variable compression level#58
bartebor wants to merge 1 commit into
google:masterfrom
bartebor:var_comp_level2

Conversation

@bartebor

Copy link
Copy Markdown

This PR makes brotli_comp_level accept variable expression.
It allows to make compression level (and its cost) variable on user defined criteria, for example cacheability of upstream response.

@eustas

eustas commented Apr 13, 2018

Copy link
Copy Markdown
Collaborator

Hello, Bartosz. Would you mind if I pick this change to my fork?

@bartebor

Copy link
Copy Markdown
Author

Hello @eustas, feel free to use this if you want - this project looks abandoned and probably no one will ever merge this in. Nice to know that you found my contribution useful ;)

@eustas

eustas commented Sep 9, 2019

Copy link
Copy Markdown
Collaborator

Hi. Overall patch looks good, but what is the use-case?
I've looked through the usage of complex variables inside nginx project, and is never used for numeric values...

@bartebor

Copy link
Copy Markdown
Author

@eustas I wanted to have a possibility of using variable compression level. That way for example I could better compress (thus use more CPU) objects cached for longer durations or with specific mime type, such as static content. This can be sometimes achieved with multiple locations, but is usually more cumbersome. The same applies to other nginx directives allowing constants only...

@fholzer

fholzer commented Jan 19, 2021

Copy link
Copy Markdown

This is great! You could set different compression level based on upstream's cache control response header. This would allow you to use better compression for resources that can be cached, and worse compression for no-cache/private resources using a map. I rebased this PR onto master in my fork, though there's still some unrelated commits in my branch which I'd like to clean up first.

@fholzer

fholzer commented Jan 20, 2021

Copy link
Copy Markdown

I added some changes to improve performance when brotli_comp_level is used with a static value. In such cases we don't want to evaluate the complex value on every http request. Instead, evaluation is done at config merge time when nginx is still starting up.
Didn't get around to do that commit cleanup, but you can still have a look if you're interested: https://github.com/fholzer/ngx_brotli/commits/variable-compression-level

@gsabran

gsabran commented Jul 1, 2021

Copy link
Copy Markdown

This is great!! Would love to see it merged :)

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

Successfully merging this pull request may close these issues.

4 participants