阅读背景:

koa-static 一些问题处理

来源:互联网 

再次复习koa-static 我发现改版了,一些代码改了

const Koa = require('koa')
const static = require('koa-static')
const router = require('koa-router')()

const server = new Koa();
router.get('/', async ctx => {
    ctx.body = "//html"
});
router.all(/((\.jpg)|(\.png)|(\.gif))$/i, static('./static', {
    maxage: 5 * 86400 * 1000
}));
router.all(/((\.js)|(\.jsx))$/i, static('./static', {
    maxage: 2 * 86400 * 1000
}));
router.all(/(\.css)$/i, static('./static', {
    maxage: 3 * 86400 * 1000
}));
router.all(/((\.html)|(\.htm))$/i, static('./static', {
    maxage: 2 * 86400 * 1000
}));
router.all('*', static('./static', {
    maxage: 3 * 86400 * 1000
}));

server.use(router.routes())
// server.use(static('./static', {
//     maxage: 1 * 86400 * 1000
// }))

server.listen(3000)const



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: