I am currently using Express 4.x and I have implemented compression middleware in my app.js file like so:
var compression = require('compression');
var app = express();
app.use(compression());
app.use('/', require('./static'));
app.use('/api/xxx', require('./api/xxx'));
Upon inspecting the Safari web inspector, I noticed that certain files such as my app.js are indeed compressed, resulting in a slight decrease in file size:
https://i.sstatic.net/QBvHd.png
However, other files such as API requests do not appear to be compressed:
https://i.sstatic.net/KIjwM.png
Given that my server simply responds with JSON data upon request, I am curious as to why the transferred data is not more heavily compressed?