sanic-ext
sanic-ext copied to clipboard
[Feature Request] Response Compression
There are several response compression libraries out there for Sanic, but they are mostly out of date, and none support the more complex streaming and chunked response case.
Using a reverse proxy is generally the best way to accomplish this for production -- such as Nginx -- but it is handy to have if one wants to limit data on the network between a reverse proxy and Sanic.
Prior art:
- sanic-compress: https://github.com/subyraman/sanic_compress. (Last commit: Mar 11, 2017)
- sanic-brogz: https://pypi.org/project/sanic-brogz/ (Project page dead, PyPI release: Oct 21, 2018)
I think it's worth discussing if perhaps this is a "batteries included" feature that could be part of sanic-ext
due to how common it is as a requirement.
I've combined the above 2 libraries into a single, modern Sanic Extension here: https://gist.github.com/dmckeone/b6d2160389640270eb24d4b0555a7768
It currently lacks streaming and chunked response compression, but I'd be interested in adding that if someone could provide me with the hooks in Sanic that would be needed to accomplish it (I couldn't find any in docs).