Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@justinpolygon
Copy link
Collaborator

@justinpolygon justinpolygon commented Mar 20, 2023

Enables gzip encoding for all HTTP requests, by adding the "Accept-Encoding: gzip" header to the request. Gzip encoding compresses the response body before sending it to the client, which reduces the size of the response and saves bandwidth.

Urllib3 supports gzip encoding out of the box. By default, urllib3 will automatically decode the gzip response if the server returns a compressed response. So, we are explicitly requesting gzip encoding via the request headers, by adding setting the Accept-Encoding header to gzip.

By enabling gzip encoding, we expect to see faster download times and reduced bandwidth usage for our users.

Server response headers without gzip:

Response headers:
Server: nginx/1.19.2
Date: Mon, 20 Mar 2023 20:40:30 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Request-Id: 630f6cb5bc2c0a317e19de7ad7255093
Strict-Transport-Security: max-age=15724800; includeSubDomains

Server response headers with gzip:

Response headers:
Server: nginx/1.19.2
Date: Mon, 20 Mar 2023 20:41:58 GMT
Content-Type: application/json
Content-Length: 1111
Connection: keep-alive
Content-Encoding: gzip
Vary: Accept-Encoding
X-Request-Id: 0fe30e077d618524ec16ec754cb96b58
Strict-Transport-Security: max-age=15724800; includeSubDomains

Client returns same results in both case.

@justinpolygon justinpolygon marked this pull request as ready for review March 20, 2023 21:02
@justinpolygon justinpolygon changed the title Force gzip encoding for faster and reduced bandwidth usage Force gzip encoding for faster response and reduced bandwidth usage Mar 20, 2023
@justinpolygon justinpolygon merged commit 4b5a3ce into master Mar 20, 2023
@justinpolygon justinpolygon deleted the jw-gzip branch March 20, 2023 22:00
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.