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

Enhance conditional HTTP compression support #218

Closed
bclozel opened this issue Nov 13, 2017 · 0 comments
Closed

Enhance conditional HTTP compression support #218

bclozel opened this issue Nov 13, 2017 · 0 comments
Labels
type/enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Nov 13, 2017

It is currently possible to configure HTTP compression in both client and server and enable this feature only if the message body is larger than minResponseSize.

Other servers like Undertow, Tomcat and Jetty allow for more flexible strategies; this is how Spring Boot supports the following options:

server.compression.enabled=false # If response compression is enabled.
server.compression.excluded-user-agents= # List of user-agents to exclude from compression.
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript # Comma-separated list of MIME types that should be compressed.
server.compression.min-response-size=2048 # Minimum response size that is required for compression to be performed.

Some servers choose to provide those options directly, others provide a Predicate based system that decides whether compression should be enabled for the given message or not. For reactor-netty, a Predicate<HttpMessage> would fit in the current picture.

I'd be happy to provide a PR if the team agrees with such a change.

See spring-projects/spring-boot#10782

@bclozel bclozel added the type/enhancement A general enhancement label Nov 13, 2017
@smaldini smaldini added this to the 0.7.x Backlog milestone Nov 15, 2017
@smaldini smaldini modified the milestones: 0.8.x Backlog, 0.7.5.RELEASE Feb 27, 2018
smaldini pushed a commit that referenced this issue Feb 27, 2018
HttpServerBuilder now exposes a compression(BiPredicate<Req,Res>).
The predicate is evaluated before committing response header/status.
If the predicate is true, compression is enabled for the given response.
The minimum compression threshold now uses content-length predicate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants