We have a Node/Express app that exposes a REST-ish API and serves a client SPA (react build) to consume it. To reduce client build size I’d love to have Glitch serve the gzipped version of our build.
Can this be done? And if ‘yes’, are there instructions on doing so?
From a quick search, I found two modules that can help you with this.
compression: much more popular, supports gzip. Usage:
var compression = require('compression')
// ...
app.use(compression())
shrink-ray-current: a less-popular fork of compression that supports Brotli, a newer compression aglorithm. It also caches the response at a higher compression for future requests, resulting in smaller sizes for both Brotli and gzip. Usage:
@j-f – I think your solution (compression) is a better idea than mine. My middleware only handles requests for .js files. compression can/will compress all http responses greater than 1kB. That’s a whole lotta nice utility!