reanahub / reana-ui

REANA UI frontend
http://reana-ui.rtfd.io
MIT License
4 stars 33 forks source link

nginx: serve gzip-compressed static files #334

Closed mdonadoni closed 1 year ago

mdonadoni commented 1 year ago

Compress JS/CSS files with gzip after yarn build and configure nginx to serve the pre-compressed files.

Closes #328

mdonadoni commented 1 year ago

Regarding the comments made in the related issue

check which format to use (depending on popularity, browser support, server side support, performance, ...)

I have chosen gzip as it is supported out-of-the-box by the nginx docker image, while also being the most popular format used on the web (see here). Brotli would need an additional extension which is not included in the official nginx docker image.

decide whether it's worth it to enable compression

When opening the homepage of REANA (with cache disabled), the transferred size goes from 1,64MB to 620kB (-62%). When opening a ROOT file, the additional JS file needed goes from 1,78MB to 510kB (-71%).

start serving compressed static files (JS sources, but also CSS), either:

Given that nginx only serves static files, it makes more sense to pre-compress them instead of compressing them on-the-fly at each request. For this reason, the gzipped-version of JS/CSS files are generated at build time.

mdonadoni commented 1 year ago

Rebased and merged!