Add cache headers for static files
This commit is contained in:
@ -27,7 +27,10 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.get('/static/*', async (ctx) => {
|
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)));
|
const stats = await sendfile(ctx, path.join(__dirname, '../dist/', ctx.path.substring(8)));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,4 +59,4 @@ koa.use(async () => {
|
|||||||
throw httpErrors.NotFound();
|
throw httpErrors.NotFound();
|
||||||
});
|
});
|
||||||
|
|
||||||
export default koa;
|
export default koa;
|
||||||
|
Reference in New Issue
Block a user