fastify-cache
v0.0.1-dev
Published
fastify plugin for caching and deduping
Downloads
4
Readme
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