From aadd533061d1c6bc6cf923194496cd30ca4d7f49 Mon Sep 17 00:00:00 2001 From: Francis Li Date: Fri, 8 Dec 2017 12:01:39 -0800 Subject: [PATCH] Fixes #491 adds support for a configurable cache-control max-age setting for serving static assets, with a default of 1d on production and 0 elsewhere (#492) --- server/server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/server.js b/server/server.js index bfd08949..f2b938c7 100644 --- a/server/server.js +++ b/server/server.js @@ -57,7 +57,9 @@ app.options('*', corsMiddleware); // Body parser, cookie parser, sessions, serve public assets -app.use(Express.static(path.resolve(__dirname, '../static'))); +app.use(Express.static(path.resolve(__dirname, '../static'), { + maxAge: process.env.STATIC_MAX_AGE || (process.env.NODE_ENV === 'production' ? '1d' : '0') +})); app.use(bodyParser.urlencoded({ limit: '50mb', extended: true })); app.use(bodyParser.json({ limit: '50mb' })); app.use(cookieParser());