Cache static assets for one year (#83)

* Cache static assets for one year

* Use milliseconds
This commit is contained in:
Alan Friedman 2019-06-14 10:24:14 -04:00 committed by GitHub
parent fa19b5098d
commit a8f479c56e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,7 +86,9 @@ const clientDistDirectory = process.env.CLIENT_DIST_DIRECTORY;
if (clientDistDirectory) { if (clientDistDirectory) {
app.use(async (ctx, next) => { app.use(async (ctx, next) => {
setStaticFileHeaders(ctx); setStaticFileHeaders(ctx);
await koaStatic(clientDistDirectory)(ctx, next); await koaStatic(clientDistDirectory, {
maxage: 365 * 24 * 60 * 60 * 1000 // one year in milliseconds
})(ctx, next);
}); });
app.use(async (ctx) => { app.use(async (ctx) => {