Compression
We can improve page load times further by compressing static files. Express includes the compress
middleware, which will gzip an HTTP response. Let's edit the Express server, /vision-web/lib/express/index.js
, and add the compress
middleware, as follows:
app.set('views', 'views'); app.use(express.logger({ immediate: true, format: 'dev' })); app.use(express.compress());
If you visit the homepage for our application and check the response headers via your browser tools for all of the resources served, you should see this:
Content-Encoding: gzip