How to active caching on Express - Node.js? How to active caching on Express - Node.js? express express

How to active caching on Express - Node.js?


You should only enable caching in production:

app.configure('production', function(){  var oneYear = 31557600000;  app.use(express.static(__dirname + '/public', { maxAge: oneYear }));  app.use(express.errorHandler());});

Furthermore you are probably better of using CDN or Nginx to host static files. A lot of CDN's aren't that expensive and I even found this free CDN at http://www.coralcdn.org/ thanks to stackoverflow.com. According to this blog post Nginx even has memcached to make your site extremely fast