how can i active the caching on Express to provide the pages quickly?
Thank you
It'll basically look for a cached value using the request's URL as the key. If it is found, it is sent directly as the response. If it's currently not cached, it'll wrap Express's send function to cache the response before actually sending it to the client and then calling the next middleware.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With