Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc