Conversation
|
Love it! |
| return | ||
| } | ||
|
|
||
| io.Copy(w, brFile) |
There was a problem hiding this comment.
io.Copy can error but we aren't handling it here. are we ok with silent failing? second, is there any benefit to using something like http.ServeContent instead?
There was a problem hiding this comment.
I didn't think we needed all of the extra stuff http.ServeContent offers here as we handle the e-tag elsewhere and don't need range support (and http.ServeContent doesn't error as it doesn't return the error from the io.CopyN call), but I don't mind changing it
There was a problem hiding this comment.
thats fine then. its not like we can set headers or anything after io.Copy has failed and if ServeContent doesnt return the io.Copy errors then we can skip it too. The client will just see a corrupted response (not like theyd be able to see anything else at this point tho so), ok LGTM
Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>
|
@ryanclark See the table below for backport results.
|
* Pre-compress web assets using Brotli * Update lib/web/brotlihandler.go Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com> --------- Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>
* Pre-compress web assets using Brotli * Update lib/web/brotlihandler.go Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com> --------- Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>
As it stands, we bundle the full JS/SVG/WASM files from the webassets build into the Teleport binary, and then gzip compress these on each request for the file. This is unnecessary as it both adds to the initial loading time of the app (before cache) and increases the
teleportbinary size.This adds Brotli compression to the Vite build (can be disabled with an environment variable for local builds as it does slow the build a bit), and updates the proxy to stream the compressed file straight to the browser.
Brotli is ~20% smaller than gzipping and all major browsers support it
Stats
teleportbinary sizeThis is a backwards compatible change as the requests from the UI to the proxy for assets stay the same and old proxies will serve the normal JS, new proxies will serve the Brotli compressed version
changelog: Webassets are now pre-compressed with Brotli