mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-30 13:20:24 +08:00
opti: 增加浏览器对 js css 缓存,加快刷新页面后的访问速度
This commit is contained in:
parent
c9d15081f4
commit
60967f715f
@ -44,6 +44,7 @@ app.use( async (ctx, next) => {
|
||||
|
||||
app.use( async (ctx, next)=>{
|
||||
if(ctx.path.indexOf('/prd') === 0){
|
||||
ctx.set('Cache-Control', 'max-age=8640000000');
|
||||
if(yapi.commons.fileExist( yapi.path.join(yapi.WEBROOT, 'static', ctx.path+'.gz') )){
|
||||
ctx.set('Content-Encoding', 'gzip')
|
||||
ctx.path = ctx.path + '.gz';
|
||||
@ -51,6 +52,7 @@ app.use( async (ctx, next)=>{
|
||||
}
|
||||
await next()
|
||||
})
|
||||
|
||||
app.use(koaStatic(
|
||||
yapi.path.join(yapi.WEBROOT, 'static'),
|
||||
{index: indexFile, gzip: true}
|
||||
|
Loading…
Reference in New Issue
Block a user