code === 0 }}); const router = require("koa-router")(); router.get("/api/test",apiCache.route({ prefix: "test", expire: 300, conditionFunc (body) { return body.code === 0; } }), async ctx => {}) If you want to clear cache. await apiCache.delCache("test"); API ...
npm i @danroshko/koa-cache Usage routes.js constRouter=require('koa-router');constcache=require('koa-cache');constcaching=cache.createMiddleware(ctx=>{// should return unique and stable cache keyreturnctx.state.user.id;});constrouter=newRouter();router.use(caching);router.get('/',ctx=>...
master koa-cache-proxy/.npmignore Go to file popomore first commit Latest commit 1f01c71 on Mar 25, 2014 History 1 contributor 6 lines (6 sloc) 59 Bytes Raw Blame test/ docs/ .npmignore .editorconfig .travis.yml .jshintrc...
https://www.npmjs.com/package...如果你是要访问图片的话,不应该用koa-static-cache,而是用koa-static。 项目根目录下新建 public/images const static = require('koa-static'); //静态资源服务 const staticPath = './public'; // 配置静态资源文件根目录 app.use(static( path.join( __dirname, stat...
$ npm install koa-static-cacheAPIstaticCache(dir [, options] [, files])var path = require('path') var staticCache = require('koa-static-cache') app.use(staticCache(path.join(__dirname, 'public'), { maxAge: 365 * 24 * 60 * 60 }))...
Static server for koa. Differences between this library and other libraries such as static: * There is no directory or index.html support. * You may optionally store the data in memory - it streams by default. * Caches the assets on initialization - you need to restart the process to upda...
百度爱采购为您找到10家最新的koa-static-cache 文件夹产品的详细参数、实时报价、行情走势、优质商品批发/供应信息,您还可以免费查询、发布询价信息等。
var cache = require('koa-rest-cache'); app.use(cache({ pattern: "/api/**/*", maxAge: 600000 // ms }));APIcache(options) A function that takes a single options argument, and returns a function generator that is intended to be passed to koa's app.use function.Options...
Router cache middleware for koa@1. Install npm i koa-router-cache --save Usage cache(app, options) Options: key: {String|GeneratorFunction} cache key. (Required) expire: {Number} expire time, in ms. (Required) get: {GeneratorFunction} custom getter function for getting data from cache...
middleware koa中间件 实例方法 #TODO getKey(url) 传入一个url,返回缓存key async getMemCache(key) 获取内存缓存 async getFileCache(key) 获取落地文件缓存 async clearMemCache(key) 清除内存缓存 async clearFileCache(key) 删除落地文件缓存 额外说明 ...