I have tested my local web server with Google's PageSpeed chrome extension. One of the results was that my web server doesn't have compression enabled. I am using node js on the backend with express 4.x. I googled a bit to find a solution to compress data and I found https://github.com/expressjs/compression a middleware for express. I tried to use it like this:
var app = express();
var compression = require('compression');
var server = http.createServer(app);
server.listen(CONFIG.PORT);
app.use(compression());
Even though I did this pageSpeed is still recommending to compress data. What am I doing wrong?
app.use(compression());
app.use(express.static(__dirname+'/public'));
Put JS, CSS, HTML files below the public
directory and they will be compressed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With