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

Variable compression level #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bartebor
Copy link

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
Copy link
Collaborator

eustas commented Apr 13, 2018

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

@bartebor
Copy link
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
Copy link
Collaborator

eustas commented Sep 9, 2019

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
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
Copy link

fholzer commented Jan 19, 2021

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
Copy link

fholzer commented Jan 20, 2021

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
Copy link

gsabran commented Jul 1, 2021

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.

None yet

4 participants