express-cache-response

1.0.2 • Public • Published

express-cache-response

npm version
Caches the response in memory of GET requests which do not have a query specified. The first time a requested path is executed, express-cache-response will hook into the response to cache it for future requests to the same url path. This can drastically improve the performance of your nodejs webserver on compiled content that doesn't change per request.

Things to look out for:

  • There is currently no way to filter what paths are cached, unless you use a regex path in app.use(path, cache()).
  • There is currently no way to clear, expire, or refresh cached content.
  • There is currently no way to specify max memory usage, and it does not check to see if it is out of memory. Use with care in production.

Installation

npm install --save express-cache-response

The add it to your application:

const cache = require('express-cache-response');
...
// Add cache middleware to app:
app.use(cache());
 
// Everything after the middleware can be cached, like below:
app.get('', function (req, res) {
    res.send('Hello World!');
});

Options

TODO: No options exist at the moment.

cache({
});

Roadmap

  • For requests that use etag and not in cache, remove etag from request, run request, cache result, and then perform etag check for response.
  • Add way to filter content to cache.
  • Add way to remove cached content via api.
  • Add way to expire cached content by a certain time or duration.
  • Add way to specify max memory usage. Least hit cached content are removed first when memory is full.
  • Add way to determine maximum amount of memory usage allowed to be used to prevent out of memory issues.
  • Add way to add custom storage engines.

License

MIT

Package Sidebar

Install

npm i express-cache-response

Weekly Downloads

4

Version

1.0.2

License

MIT

Last publish

Collaborators

  • dillonu