Skip to content

feat: gzip static http server assets #2272

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

Merged
merged 4 commits into from
Jun 13, 2022
Merged

feat: gzip static http server assets #2272

merged 4 commits into from
Jun 13, 2022

Conversation

coadler
Copy link
Contributor

@coadler coadler commented Jun 12, 2022

Agent binary downloads go from 30MB to 13MB!

Agent binary downloads go from 30MB to 13MB!
@coadler coadler self-assigned this Jun 12, 2022
@coadler coadler requested a review from kylecarbs June 12, 2022 20:12
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Nice, I was thinking we should do this as I was investigating #2202, glad you got around to it!

PS. I don't think the use of middleware here is a blocker (i.e. we can go ahead with gziphandler), but I do think supporting more than gzip may be beneficial in the browser environment (considering we're serving the entire site package behind the handler).

coderd/coderd.go Outdated
@@ -350,7 +351,8 @@ func New(options *Options) *API {
r.Get("/state", api.workspaceBuildState)
})
})
r.NotFound(api.siteHandler.ServeHTTP)

r.NotFound(gziphandler.GzipHandler(http.HandlerFunc(api.siteHandler.ServeHTTP)).ServeHTTP)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to prefer gziphandler vs chi/middleware.Compress here? The Chi one also supports deflate. (I think it would be nice to support all of: deflate, gzip and br (brotli), but chi does not handle br.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that one looks better!

@coadler coadler merged commit dad42fe into main Jun 13, 2022
@coadler coadler deleted the colin/static-gzip branch June 13, 2022 18:14
@coadler
Copy link
Contributor Author

coadler commented Jun 13, 2022

We should def remove this once we start to actually store gzip'd assets, but this is a pretty quick win especially when using the dev tunnel.

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