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

compress .metadata files if client supports #134

Merged
merged 2 commits into from
May 11, 2023
Merged

Conversation

ewdurbin
Copy link
Member

No description provided.

@ewdurbin
Copy link
Member Author

pairs with pypi/warehouse#13649

@ewdurbin ewdurbin merged commit 1db2c3b into main May 11, 2023
@ewdurbin ewdurbin deleted the compress_metadata branch May 11, 2023 19:21
# Perform compression if the client claims to understand it
if (req.http.Accept-Encoding == "gzip") {
set beresp.gzip = true;
} else if (req.http.Accept-Encoding == "br") {
Copy link

@ddelange ddelange May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! 👋

Is there a particular reason to prefer gzip over brotli? Especially for perdominantly English vocabulary, brotli outperforms gzip both in terms of time and compression ratio.

Here's a quick benchmark I did recently: illagrenan/django-brotli#117

Copy link

@ddelange ddelange May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the more general question is: what happens if the client accepts multiple encodings?

Like requests and aiohttp and probably most others do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any reason to prefer gzip over brotli, though I suspect the answer is that it doesn't matter regardless because 99% of the traffic will be gzip anyways because the primary consumer will almost certainly be pip, which uses requests which, afaik, doesn't support brotli by default (requires extra libraries, and likely would get disabled in pip anyways because C libraries cant be upgraded on Windows if pip imports them).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the point in the request that this happens, the Accept-Encoding header is normalized to only be a single encoding.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the elaborate response!

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