🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

fastify-cache

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-cache

fastify plugin for caching and deduping

0.0.1-dev
latest
npm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 14 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts