Caching

Our static file requirements are minimal; the only static content we serve would be the components used on the client side of our application. In order to cache our static files/components, let's make a simple change to vision-web/lib/express/index.js. We set the maxAge property to a week, which we store in config, as follows:

app.use(express.static('public', { maxAge: config.get('express:staticCache') })); app.use(express.static('public/components', { maxAge: config.get('express:staticCache') })); app.use('/bootstrap',express.static('public/components/bootstrap/docs/assets/css', { maxAge: config.get('express:staticCache') })); app.use('/sockets', express.static('public/components/socket.io-client/dist/', { maxAge: config.get('express:staticCache') ...

Get Advanced Express Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.