Change cache-control heeaders (#6355)

This commit is contained in:
Nacho García
2021-06-17 20:55:27 +02:00
committed by rijkvanzanten
parent 5eb95c3a0e
commit b856810e7a
2 changed files with 3 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ const checkCacheMiddleware: RequestHandler = asyncHandler(async (req, res, next)
if (env.CACHE_ENABLED !== true) return next();
if (!cache) return next();
if (req.headers['cache-control']?.includes('no-cache') || req.headers['Cache-Control']?.includes('no-cache')) {
if (req.headers['cache-control']?.includes('no-store') || req.headers['Cache-Control']?.includes('no-store')) {
return next();
}

View File

@@ -15,10 +15,10 @@ export function getCacheControlHeader(req: Request, ttl: number | null): string
if (env.CACHE_AUTO_PURGE === true) return 'no-cache';
const noCacheRequested =
req.headers['cache-control']?.includes('no-cache') || req.headers['Cache-Control']?.includes('no-cache');
req.headers['cache-control']?.includes('no-store') || req.headers['Cache-Control']?.includes('no-store');
// When the user explicitly asked to skip the cache
if (noCacheRequested) return 'no-cache';
if (noCacheRequested) return 'no-store';
// Cache control header uses seconds for everything
const ttlSeconds = Math.round(ttl / 1000);