-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
get-index: Enable deflate and gzip compression #3677
Conversation
d555d9e
to
2738585
Compare
Thank you @the-kenny. I'd held off adding gzip compression because I was worried that without caching the load on the server could get unmanageable. Having said that I haven't done any testing on the CPU load of compression. I don't think it's a problem to ignore caching if we add a switch to make compression optional, but I'd like to try to implement it in a way that makes it easy to add it to other routes. |
@Jermolene thanks for the response! While I don't have any benchmarks, I don't think enabling gzip compression like this results in any excess CPU load on any machine. I don't feel any difference on my old and rusty Raspberry Pi, but that's completely subjective. As I wrote earlier, I like the idea of making this generic, but that would need some work. We can either refactor the response handling by introducing a middleware layer, or we could wrap the Would it be enough (for now) to add a new CLI-option to the |
Hi @the-kenny
Yes I think adding a In terms of the implementation I'm not sure which approach would be best. Making the middleware handling more generally flexible is desirable, but I'd be open to other approaches. If you're willing to have a go at this I'll be happy to help where I can. |
@Jermolene Added the option. Thanks for the hints! :-) Note that I added |
Many thanks @the-kenny, looks good. |
* get-index: Enable deflate and gzip compression * Spaces -> Tabs * listen: Add optional `gzip=yes` parameter (defaults to "no") * get-index: Add comment explaining the usage of `zlib.*Sync` instead of async.
Big wikis can take some time to load over bigger connections when using the Node server. This pull requests enables
deflate
andgzip
compression on theget-index
route which massively reduces the amount of transferred data.It uses the
zlib
node module and (for simplicity) uses thesync
versions of the functions. It's also possible to use the non-sync versions without much hassle.I plan on abstracting this logic a big and add it to other routes which serve non-trivial amounts of data.