Route-Cache

Caching middleware for Express (w/ expiration)

View repo on Github >>

Make your routes do this ->dodging

Why?

  • makes hard-working routes super-fast, under heavy-load, see Load Tests
  • easy to use and fork for your needs
  • works with gzip compression

Install

npm install route-cache

Test

npm test

How to use


var routeCache = require('route-cache');

// cache route for 20 seconds
app.get('/index', routeCache.cacheSeconds(20), function(req, res){
    // do your dirty work here...
    console.log('you will only see this every 20 seconds.');
    res.send('this response will be cached');
});


Delete a cached route

routeCache.removeCache('/index');

Future plans / todos

  • client-side Cache-Control
  • support for distributed caches (redis or memcache)