Enabling gzip compression
It seems that the production environment is not using gzip compression for any of the served contents. As gzipping specific mimetypes and minimum file sizes can significantly increase the responsiveness of the site, I would be strongly in favour of adding this compression. Most big sites use some form of compression and the client can also actually selectively disable it. Browsers request/allow gzipped contents by default with the Accept-Encoding
-header.
My suggestion would be:
- Enable level 1 gzip compression by default for all .html, .js, and .css files that are above 1024 kB
- For JSON responses we could either enable compression on nginx level with a mimetype, or then use python decorators on the routes that we want to compress. The only reason why we would want to go with the decorator approach is that then users could explicitly control the gzip compression with a custom request field. The "Accept-Encoding" header may not be as explicit for an API user, although it is the current standard.
I would be more than happy to test this and do some benchmarks for the gui and API.
Regarding Flask compression: There are some plugins that can enable the compression for the whole app. Currently, in the encyclopedia-api route I implemented a custom decorator that can be applied selectively to any route that should be compressed. With this decorator, I was able to get 5x size reduction for the large JSON contents which resulted also in very noticeable increase in the encyclopedia responsiveness since the bandwidth is typically the limiting factor with > 1mb files.