Skip to content

Commit aadd533

Browse files
francislicatarak
authored andcommitted
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)
1 parent 82ca755 commit aadd533

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ app.options('*', corsMiddleware);
5757

5858
// Body parser, cookie parser, sessions, serve public assets
5959

60-
app.use(Express.static(path.resolve(__dirname, '../static')));
60+
app.use(Express.static(path.resolve(__dirname, '../static'), {
61+
maxAge: process.env.STATIC_MAX_AGE || (process.env.NODE_ENV === 'production' ? '1d' : '0')
62+
}));
6163
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
6264
app.use(bodyParser.json({ limit: '50mb' }));
6365
app.use(cookieParser());

0 commit comments

Comments
 (0)