Add cache headers for static files

This commit is contained in:
Jori Lallo 2016-06-01 16:48:35 -07:00
parent 01f026712e
commit 72766966f3
1 changed files with 5 additions and 2 deletions

View File

@ -27,7 +27,10 @@ if (process.env.NODE_ENV === 'production') {
});
router.get('/static/*', async (ctx) => {
console.log(path.join(__dirname, '../dist/', ctx.path.substring(8)));
ctx.set({
'Cache-Control': 'max-age=999999999999',
});
const stats = await sendfile(ctx, path.join(__dirname, '../dist/', ctx.path.substring(8)));
});
@ -56,4 +59,4 @@ koa.use(async () => {
throw httpErrors.NotFound();
});
export default koa;
export default koa;