From 4d811541519fdf6db4c1fd1f40b0f1a88a50c866 Mon Sep 17 00:00:00 2001 From: oruburos Date: Fri, 17 Jul 2020 22:02:05 +0100 Subject: [PATCH] Server.js Change in Cache Policy --- server/server.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/server.js b/server/server.js index b78469a6..d82aa6d8 100644 --- a/server/server.js +++ b/server/server.js @@ -75,7 +75,18 @@ app.use(corsMiddleware); app.options('*', corsMiddleware); // Body parser, cookie parser, sessions, serve public assets -app.use('/locales', Express.static(path.resolve(__dirname, '../dist/static/locales'), { cacheControl: false })); +app.use( + '/locales', + Express.static( + path.resolve(__dirname, '../dist/static/locales'), + { + // Browsers must revalidate for changes to the locale files + // It doesn't actually mean "don't cache this file" + // See: https://jakearchibald.com/2016/caching-best-practices/ + setHeaders: res => res.setHeader('Cache-Control', 'no-cache') + } + ) +); app.use(Express.static(path.resolve(__dirname, '../dist/static'), { maxAge: process.env.STATIC_MAX_AGE || (process.env.NODE_ENV === 'production' ? '1d' : '0') }));