Skip to content

telus/cachepile-middleware

Repository files navigation

Logo

Cachepile Express Middleware version License Build Status

CachePile Express Middleware

Install

npm install --production --save @cachepile/middleware

API

lib()

Middleware usage

const express = require('express')
const middleware = require('@cachepile/middleware')

const app = express()
app.use(middleware())
app.listen(3000, () =>  console.log(`Cachepile listening on 3000`))

Configs

You can pass in an options object into the middleware initialization. Here are the options:

Key Description Default Value
headerPrefix specify the prefix for the headers cp
redis redis node is used under the hood. See a list of options here

Client usage

# call api to cache through the proxy
curl -i -H "cp-target-port: 443" -H "cp-ttl: 10" -H "CP-TARGET-HOST: reqres.in" -H "CP-TARGET-PROTO: https"  localhost:3000/api/users

Headers

Header Description Default Value
CP-FORCE Force request to call through to specified end point false
CP-TARGET-HOST host of endpoint to cache requested host
CP-TARGET-PORT port of endpoint to cache requested port
CP-TARGET-PROTO protocol for endpoint to cache http
CP-TTL time in seconds to cache response 1
CP-WAIT if set to false(default) the proxy will wait for the response from the server before responding to the client request. Otherwise, it will return 201 and fetch the request in the background. false

License: ISC • Copyright: ahmadnassri.com • Github: @ahmadnassri • Twitter: @ahmadnassri

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published