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

Look for all accepted encodings for precompressed files but keeping the quality ordering #439

Merged

Conversation

kobutri
Copy link
Contributor

@kobutri kobutri commented May 10, 2024

Description

Instead of only looking for a precompressed file matching the preferred encoding, I check for all accepted encodings.

Related Issue

#438

Motivation and Context

Crome accepts brotli and brotli is generally superior to gzip, but Chrome always lists gzip first in the Accept-Encoding header.
#438

How Has This Been Tested?

I created a new brotli compressed index.html.br and created a test that accepts deflate, br. Because of this change the index.html.br will be returned, where previously no compressed file would be returned.

Screenshots (if appropriate):

Copy link

semanticdiff-com bot commented May 10, 2024

Review changes with SemanticDiff.

Analyzed 4 of 5 files.

Overall, the semantic diff is 51% smaller than the GitHub diff.

Filename Status
✔️ src/compression.rs Analyzed
✔️ src/compression_static.rs 88.02% smaller
✔️ tests/compression_static.rs Analyzed
✔️ tests/dir_listing.rs 3.52% smaller
tests/fixtures/public/404.html.br Unsupported file format

@joseluisq joseluisq added enhancement New feature or request v2 v2 release labels May 16, 2024
@joseluisq joseluisq changed the title Look for all accepted encodings for precompressed files Look for all accepted encodings for precompressed files but keeping the quality ordering May 16, 2024
@joseluisq joseluisq linked an issue May 16, 2024 that may be closed by this pull request
1 task
Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

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

The idea is not bad. In fact, it helps SWS to decide better which file to serve.
FYI I just fixed syntax issues and improved the test a bit.

Thanks!

@joseluisq joseluisq merged commit 7f59da9 into static-web-server:master May 16, 2024
34 checks passed
@joseluisq joseluisq added this to the v2.31.0 milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v2 v2 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Look for all accepted encodings for precompressed files
2 participants