Add cache headers for static files
This commit is contained in:
parent
01f026712e
commit
72766966f3
|
@ -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;
|
||||
|
|
Reference in New Issue