Enable nginx gzip compression to reduce page weight
At present, the Nginx install on FreeNAS 11.2 is serving its resources without using Gzip compression.
This means that, for example, the new Angular-based UI requires a lot more data to be transferred and is slower to load than necessary.
For the new UI specifically, when uncompressed, the initial requests required to load the UI consume 6.14MB (after fixes I made in https://redmine.ixsystems.com/issues/63630 are used). With use of the following Nginx configuration, which enables gzip for text-based mime types, the data transfer required drops to just 1.64MB (saving 4.5MB or 73%):
Unrelated config has been omitted.
This change has the effect of speeding up the UI, even for a nearby LAN-connected NAS, and particularly so for a NAS which is being accessed over connections like cellular. See the attached comparison screenshots of before and after enabling gzipping, loaded on a 1GbE LAN, in Firefox with browser caching disabled. Note the blue is "waiting" and green is "receiving"; both are greatly decreased after gzipping is on. The total request time for the whole page comes down to the websocket connection, which is highly variable, so best to focus on the individual resources themselves (eg main.js goes from 922ms down to just 29ms). Greater time savings occur as the network speed decreases. In this proof-of-concept Gzipping is done dynamically for all requests, however for the static Angular resources, these could be gzipped ahead of time, saving both downloads and CPU time.
Gzipping adds a little CPU overhead (precise figures aren't clear) but the result is that requests and pages require much less data and thus end up loading a lot more quickly. See more info at https://royal.pingdom.com/2018/08/15/can-gzip-compression-really-improve-web-performance/
So, it makes sense to be enabling gzip for the new web UI as it has a significant positive impact on load times. However, Nginx on FreeNAS is serving more than just this UI though, such as documentation, APIs and so on. All these other endpoints could benefit in similar manners -- so thoughts on applying this gzipping for all of the content served? Responses like images or fonts are usually not compressed as they don't give the savings that text does.
Happy to create a PR for this if required; I just need some guidance on which file(s) to modify since a quick look shows several
nginx.conf files are present in the repo at https://github.com/freenas/freenas/
#12 Updated by David Beitey about 1 year ago
Bug Clerk wrote:
LGTM. With gzipping, login page data transfer drops from 6.18MB to 1.48MB.