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

feat: web server compression #9287

Merged
merged 1 commit into from
May 31, 2024
Merged

Conversation

JammingBen
Copy link
Contributor

Description

Adds a compression middleware to the web server to reduce the request size when delivering static files. This speeds up loading times in web clients.

The chi middleware we're using for this currently supports gzip as compression algorithm. We might want to extend this to support br (Brotli) in the future, since it's a newer and more performant algorithm. But for now, any compression is a big step up.

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Adds a compression middleware to the web server to reduce the request size when delivering static files. This speeds up loading times in web clients.

The chi middleware we're using for this currently supports `gzip` as compression algorithm. We might want to extend this to support `br` (Brotli) in the future, since it's a newer and more performant algorithm.
@JammingBen JammingBen self-assigned this May 31, 2024
@JammingBen JammingBen requested a review from kulmann as a code owner May 31, 2024 10:41
Copy link

sonarcloud bot commented May 31, 2024

Copy link
Member

@kulmann kulmann left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Collaborator

@kobergj kobergj left a comment

Choose a reason for hiding this comment

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

Found this in the docs about Compress middleware:

NOTE: make sure to set the Content-Type header on your response otherwise this middleware will not compress the response body. For ex, in your handler you should set w.Header().Set("Content-Type", http.DetectContentType(yourBody)) or set it manually.

Are we doing this already?

@JammingBen
Copy link
Contributor Author

Found this in the docs about Compress middleware:

NOTE: make sure to set the Content-Type header on your response otherwise this middleware will not compress the response body. For ex, in your handler you should set w.Header().Set("Content-Type", http.DetectContentType(yourBody)) or set it manually.

Are we doing this already?

Seems to be the case, although I can't tell where exactly this happens (I guess here ?). All responses have a Content-Type header and compression works just fine.

@fschade
Copy link
Contributor

fschade commented May 31, 2024

Found this in the docs about Compress middleware:

NOTE: make sure to set the Content-Type header on your response otherwise this middleware will not compress the response body. For ex, in your handler you should set w.Header().Set("Content-Type", http.DetectContentType(yourBody)) or set it manually.

Are we doing this already?

Seems to be the case, although I can't tell where exactly this happens (I guess here ?). All responses have a Content-Type header and compression works just fine.

exactly, all static assets use the assets server, so LGTM

@JammingBen JammingBen merged commit fc55b7c into master May 31, 2024
4 checks passed
@delete-merged-branch delete-merged-branch bot deleted the feat/web-server-compression branch May 31, 2024 12:43
ownclouders pushed a commit that referenced this pull request May 31, 2024
@micbar micbar mentioned this pull request Jun 19, 2024
24 tasks
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.

None yet

4 participants