Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Add compression to haproxy #11272

wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 8, 2016

The compression to haproxy.

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

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?

Copy link
Author

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)

Copy link
Contributor

@knobunc knobunc left a 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.

@knobunc
Copy link
Contributor

knobunc commented Oct 12, 2016

@ramr PTAL

When the env var ROUTER_ENABLE_COMP set to any value will the compression for haproxy be enabled
@ghost
Copy link
Author

ghost commented Oct 12, 2016

Okay now added.
I hope that not to much complication will be added for such a small enhancement.

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

@ramr ramr Oct 12, 2016

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.

Copy link
Author

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 ..."?

Copy link
Contributor

@ramr ramr Oct 14, 2016

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.

@ramr
Copy link
Contributor

ramr commented Oct 19, 2016

@cw-aleks this looks good. Can you please squash into a single commit. Thx
[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to a272940

@knobunc
Copy link
Contributor

knobunc commented Oct 19, 2016

@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

@ghost
Copy link
Author

ghost commented Oct 19, 2016

Thanks for the feedback.
Well I do this git stuff with the web interface of github.
Is there such a option of squash?

@knobunc
Copy link
Contributor

knobunc commented Oct 19, 2016

@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.

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10271/) (Base Commit: 5134734)

@ghost ghost mentioned this pull request Oct 20, 2016
@ghost
Copy link
Author

ghost commented Oct 20, 2016

Ok created new pr #11469

@ghost ghost closed this Oct 20, 2016
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants