Fix review comments: add a new constant for no-cache header value.

Signed-off-by: David Festal <dfestal@redhat.com>
This commit is contained in:
David Festal
2024-01-22 16:10:05 +01:00
parent 2c27289bd1
commit 0a659c9b1d
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -16,3 +16,4 @@
export const CACHE_CONTROL_NO_CACHE = 'no-store, max-age=0';
export const CACHE_CONTROL_MAX_CACHE = 'public, max-age=1209600'; // 14 days
export const CACHE_CONTROL_REVALIDATE_CACHE = 'no-cache'; // require revalidating cached responses before reuse them.
+2 -1
View File
@@ -35,6 +35,7 @@ import {
import {
CACHE_CONTROL_MAX_CACHE,
CACHE_CONTROL_NO_CACHE,
CACHE_CONTROL_REVALIDATE_CACHE,
} from '../lib/headers';
// express uses mime v1 while we only have types for mime v2
@@ -135,7 +136,7 @@ export async function createRouter(
express.static(resolvePath(appDistDir, 'static'), {
setHeaders: (res, path) => {
if (path === injectedConfigPath) {
res.setHeader('Cache-Control', 'no-cache');
res.setHeader('Cache-Control', CACHE_CONTROL_REVALIDATE_CACHE);
} else {
res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);
}