mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
Change cache-control heeaders (#6355)
This commit is contained in:
committed by
rijkvanzanten
parent
5eb95c3a0e
commit
b856810e7a
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user