fastify-cache

0.0.1-dev • Public • Published

fastify-cache

TODO intro

Quick Start

const cache = require('fastify-cache')
const app = require('fastify')()

app.register(cache, {
  ttl: 60,
  // see matching (TODO)
  request: {
    method: ['GET', 'OPTIONS'],
    url: true // any url
  }
})

app.get('/', {
  cache: {
    ttl: 10,
    request: {
      // do not cache requests that have "Authorization"
      headers: (headers) => !headers.authorization
    }
    xheaders: false // do not set "x-cache" header to tell miss or hit
  }
}, 
async (request, reply) => {
  return { hello: 'world' }
})

await app.listen(3000)

Options

TODO

plugin and route options

  • ttl
  • storage (see async dedupe)
  • onDedupe (see async dedupe)
  • onHit (see async dedupe)
  • onMiss (see async dedupe)
  • onError (see async dedupe)
  • references (see async dedupe)
  • invalidate (see async dedupe)
  • xheaders
  • request (see matching)
    • method
    • url
    • query
    • body
    • headers

route: cache: false disable cache for the single route

Matching

TODO

Invalidation

TODO

Caveats

  • dedupe requires ttl minimum 1 second
  • stream are not supported

Readme

Keywords

none

Package Sidebar

Install

npm i fastify-cache

Weekly Downloads

2

Version

0.0.1-dev

License

MIT

Unpacked Size

98.4 kB

Total Files

19

Last publish

Collaborators

  • simone.sanfra