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') }));
Let's add the config value, staticCache
, to vision-web/config/*.json
, as follows:
"express": { "port": 8443, "staticCache" : 6048000000 },
Now, when we hit our application, the response headers will have a cache-control...