Socket
Book a DemoInstallSign in
Socket

@p-j/eapi-middleware-cache

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@p-j/eapi-middleware-cache

A cache middleware to work within an EAPI app. Check worker-eapi-template for context.

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

@p-j/eapi-middleware-cache

A middleware to configure cache behavior on a per route or request basis

Installation

  • From the NPM registry
npm install @p-j/eapi-middleware-cache
# or
yarn add @p-j/eapi-middleware-cache

API

withCache is a Middleware Factory; it takes the following options:

export interface WithCacheOptions {
  cacheControl?: string
  cdnTtl?: number
  cacheError?: boolean
  varyHeaders?: string[]
  serverTimings?: boolean
}

As noted above, none of the options are required.

  • cacheControl the value to be assigned to the Cache-Control header (control the Browser Cache TTL)
  • cdnTtl this control the Edge Cache TTL, by default it also sets a Cache-Control of the same value, unless cacheControl is also set
  • cacheCacheError wheter or not to cache errors. Defaults to false.
  • varyHeaders an array of Header names to be add to the Vary header (eg: 'Accept', 'Origin' ... ).
  • serverTimings=true add Server-Timing header with cache interaction information. Defaults to true.

For a better understanding of how cache works in the context of Cloudflare Workers, these links may help:

And for the underlying API

Keywords

eapi

FAQs

Package last updated on 17 Mar 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.