koa-varnish
The cache middleware for koa, it can cache the data such as varnish. The cache ttl is use the value of s-maxage
or maxage
from response header: Cache-Control
.
Uncacheable list:
- Method isn't 'GET' or 'HEAD'
- Function isCacheable return false
- HTTP response status is not 200, 203, 204, 300, 301, 302, 304, 307, 404, 410, 414
- Get max-age form response header
Cache-Control
isn't gt 0
Installation
$ npm i koa-varnish
API
hash
Get the key for the cache, default is${ctx.method}-${ctx.url}
isCacheable
Check the request is cacheable, default is all true.cache
The opotions for lru-cachehitForPass
The max-age for hit for pass, default is300 * 1000
ms
const cache = ;const Koa = ;const app = ; app; app;
License
MIT