Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-cash

Package Overview
Dependencies
Maintainers
5
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-cash - npm Package Compare versions

Comparing version 4.0.5 to 4.1.0

4

index.js

@@ -14,3 +14,3 @@ const { gzip } = require('zlib');

// methods we cache
const methods = {
const defaultMethods = {
HEAD: true,

@@ -23,2 +23,4 @@ GET: true

const methods = Object.assign(defaultMethods, options.methods);
const hash =

@@ -25,0 +27,0 @@ options.hash ||

{
"name": "koa-cash",
"description": "HTTP response caching for Koa. HTTP response caching for Koa. Supports Redis, in-memory store, and more!",
"version": "4.0.5",
"version": "4.1.0",
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",

@@ -55,2 +55,5 @@ "ava": {

},
"files": [
"index.js"
],
"homepage": "https://github.com/koajs/cash",

@@ -57,0 +60,0 @@ "husky": {

@@ -13,17 +13,26 @@ # koa-cash

Table of Contents
## Table of Contents
* [koa-cash](#koa-cash)
* [Features](#features)
* [Install](#install)
* [Usage](#usage)
* [API](#api)
* [app.use(koaCash(options))](#appusekoacashoptions)
* [`maxAge`](#maxage)
* [`threshold`](#threshold)
* [`compression`](#compression)
* [`setCachedHeader`](#setcachedheader)
* [`methods`](#methods)
* [`hash()`](#hash)
* [`get()`](#get)
* [`set()`](#set)
* [Example](#example)
* [Max age](#max-age)
* [Notes](#notes)
* [Usage](#usage-1)
* [Contributors](#contributors)
* [License](#license)
* [Links](#links)
* [Features](#features)
* [Install](#install)
* [Usage](#usage)
* [API](#api)
* [app.use(koaCash(options))](#appusekoacashoptions)
* [const cached = await ctx.cashed(\[maxAge\])](#const-cached--await-ctxcashedmaxage)
* [Notes](#notes)
* [Usage](#usage-1)
* [Contributors](#contributors)
* [License](#license)
## Features

@@ -39,6 +48,5 @@

## Install
[npm][]:
[NPM](https://www.npmjs.com/)

@@ -49,3 +57,3 @@ ```sh

[yarn][]:
[Yarn](https://yarnpkg.com/)

@@ -56,12 +64,19 @@ ```sh

## Usage
```js
const koaCash = require('koa-cash');
import LRU from 'lru-cache';
import koaCash from 'koa-cash';
// ...
const cache = new LRU();
app.use(koaCash({
get: (key) => {
return cache.get(key);
},
set(key, value) {
return cache.set(key, value);
},
}))
app.use(koaCash())
app.use(async ctx => {

@@ -78,3 +93,2 @@ // this response is already cashed if `true` is returned,

## API

@@ -102,2 +116,8 @@

#### `methods`
If an object is passed, then add extra HTTP method caching. This value is empty by default. But `GET` and `HEAD` are enabled.
Eg: `{ POST: true }`
#### `hash()`

@@ -163,4 +183,6 @@

### const cached = await ctx.cashed(\[maxAge])
### Max age
const cached = await ctx.cashed(\[maxAge])
This is how you enable a route to be cached. If you don't call `await ctx.cashed()`, then this route will not be cached nor will it attempt to serve the request from the cache.

@@ -172,3 +194,2 @@

## Notes

@@ -180,6 +201,4 @@

## Usage
## Contributors

@@ -192,3 +211,2 @@

## License

@@ -198,7 +216,5 @@

## Links
##
[npm]: https://www.npmjs.com/
[yarn]: https://yarnpkg.com/
* [NPM](https://www.npmjs.com/)
* [Yarn](https://yarnpkg.com/)
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