From 60967f715f2f1ce690aeed0c7abaf27b44ba1ebe Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Sun, 5 Nov 2017 16:17:00 +0800 Subject: [PATCH] =?UTF-8?q?opti:=20=E5=A2=9E=E5=8A=A0=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8=E5=AF=B9=20js=20css=20=E7=BC=93=E5=AD=98=EF=BC=8C?= =?UTF-8?q?=E5=8A=A0=E5=BF=AB=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E5=90=8E?= =?UTF-8?q?=E7=9A=84=E8=AE=BF=E9=97=AE=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/app.js b/server/app.js index 178ee8b2..3499b738 100755 --- a/server/app.js +++ b/server/app.js @@ -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}