express-cache-tags

1.0.0 • Public • Published

express-cache-tags

npm version Downloads/week License build status coverage

A (not yet) fully featured cache-tagging solution for node servers.


Motivation

Most HTTP servers rely on third-party systems for caching (such as CDNs). Even though this is probably the right approach, sometimes we need a fully featured, local, and simple caching and puring solution for a varying number of reasons. Whatever the reason is for you, we got you covered!

Usage

Installation

npm i express-cache-tags

Usage

Middleware

import express from 'express'
import cache from 'express-cache-tags'

express()
  .use(cache())
  // .get(...) your server routes
  .listen(3000)

Options

All the usage options receive the same options object:

prop description default
cacheFactory A cache-object factory A new memory-cache instace
generateKey A cache-key generator (req) => \${req.method}:${rq.url}``
shouldCache Predicate to decide caching () => true // cache anything the middleware touches
statusHeader Hitting status header name 'CDN-Cache'
logger Logging specific options
logger.enabled Wheter or not to log operations true
logger.scope Logging scope (see signale) 'CACHE'
cacheTags Cache-tags specific options
cacheTags.extract Request cache-tags extractor `(req, res) => (res.get('Cache-Tags')
purger Purging specific options
purger.extract Purging tags extractor `(req, res) => (req.query.invalidate
Cache-object

A memory-cache compatible object, with at least get, put, keys, and clear methods.

Readme

Keywords

none

Package Sidebar

Install

npm i express-cache-tags

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

442 kB

Total Files

17

Last publish

Collaborators

  • lucasconstantino