-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add compression to haproxy #11272
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
Add compression to haproxy #11272
Conversation
The compression to haproxy.
@@ -68,6 +68,15 @@ defaults | |||
timeout tunnel 1h | |||
{{ end }} | |||
|
|||
# enable compression. | |||
# http://cbonte.github.io/haproxy-dconv/1.5/configuration.html#4-compression | |||
compression algo gzip |
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.
Does this respect accept-encoding headers?
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.
Yes.
These are the reasons when compression will not be used.
Compression is disabled when:
* the request does not advertise a supported compression algorithm in the
"Accept-Encoding" header
* the response message is not HTTP/1.1
* HTTP status code is not 200
* response header "Transfer-Encoding" contains "chunked" (Temporary
Workaround)
* response contain neither a "Content-Length" header nor a
"Transfer-Encoding" whose last value is "chunked"
* response contains a "Content-Type" header whose first value starts with
"multipart"
* the response contains the "no-transform" value in the "Cache-control"
header
* User-Agent matches "Mozilla/4" unless it is MSIE 6 with XP SP2, or MSIE 7
and later
* The response contains a "Content-Encoding" header, indicating that the
response is already compressed (see compression offload)
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.
Thanks for the patch.
Can you make this controlled by an environment variable please? I can imagine that not everyone wants it enabled by default.
@ramr PTAL |
When the env var ROUTER_ENABLE_COMP set to any value will the compression for haproxy be enabled
Okay now added. |
# TODO: {{env "ROUTER_SERVICE_COMP_MIME" "application/json text/css application/javascript"}} | ||
# How handle the env routine blanks in env vars? | ||
# https://github.com/openshift/origin/blob/master/pkg/router/template/plugin.go#L93 | ||
compression type text/html text/plain text/css application/javascript |
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.
Maybe use something like:
{{ with $mimeType := (env "ROUTER_SERVICE_COMP_MIME" "") }}
compression algo gzip
compression type {{$mimeType}}
{{end}}
There's some examples further on in this file.
Edited add the compression algo only if the env var is set.
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.
Works this also with the BLANK seperator?
I mean when I do the following
oc env router ROUTER_SERVICE_COMP_MIME="text/html text/plain text/css application/javascript"
Will this be 1:1 in the line of "compression type ..."?
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.
Yes it would be 1:1 to the line you expect
compression type text/html text/plain text/css application/javascript
Note, slight typo you do need to use oc env dc/router ...
but yeah, it would pass whatever the env variable is set.
@cw-aleks this looks good. Can you please squash into a single commit. Thx |
Evaluated for origin test up to a272940 |
@cw-aleks sorry for the slow reply. Thanks for making the change. Can you rename the variables from COMP to COMPRESSION, and squash and we'll get it in? The longer names will be a little more clear to people looking at the pod definitions. Thanks |
Thanks for the feedback. |
@cw-aleks Sorry... I don't think it's possible to squash through the UI outside of a merge... but our merges happen from a bot so that doesn't help. |
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10271/) (Base Commit: 5134734) |
Ok created new pr #11469 |
The compression to haproxy.