开发者

How to active caching on Express - Node.js?

开发者 https://www.devze.com 2023-03-17 17:24 出处:网络
how can i active the caching on Express to provide the pages quickly? T开发者_如何学JAVAhank youYou should only enable caching in production:

how can i active the caching on Express to provide the pages quickly?

T开发者_如何学JAVAhank you


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

0

精彩评论

暂无评论...
验证码 换一张
取 消