http: enable h2o's response compression #950
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a compression handler, configured to support gzip and brotli for responses of non-trivial size.
The library takes care of applying compression only on content types where this makes sense. For now, we're deferring to h2o's defaults, which is essentially a whitelist containing most common text-based mime types.
We lightly adjust the
h2o_add_header_by_strcall so that h2o tokenizes our headers appropriately, letting it detect the content type.With this change, we see bytes-over-the-wire reduced as expected.
A cache refresh of the groups web client on a ship with very little content (so, primarily .js file downloads) goes down from ~10mb to ~3mb transferred. (~30%)
Filling a channel with small posts by the same author gives a "recent posts" json scry result of ~23kb, but only uses ~3kb over the wire. (~13%!)
Happy to bikeshed the compression configuration here. I just picked values that seemed fairly middle-of-the-road.