From ebefe775bbdcb9997f9ddcbaabb9a868d7e42c59 Mon Sep 17 00:00:00 2001 From: victorvhs017 <115753265+victorvhs017@users.noreply.github.com> Date: Tue, 25 Mar 2025 22:53:59 -0300 Subject: [PATCH] fix: updated ttl property on cache-handler (#5065) --- apps/web/cache-handler.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/cache-handler.mjs b/apps/web/cache-handler.mjs index 5292d88e97..1065fa3b83 100644 --- a/apps/web/cache-handler.mjs +++ b/apps/web/cache-handler.mjs @@ -57,8 +57,6 @@ CacheHandler.onCreation(async () => { timeoutMs: 1000, }; - redisHandlerOptions.ttl = Number(process.env.REDIS_DEFAULT_TTL) || 86400; // 1 day - // Create the `redis-stack` Handler if the client is available and connected. handler = await createRedisHandler(redisHandlerOptions); } else { @@ -70,6 +68,11 @@ CacheHandler.onCreation(async () => { return { handlers: [handler], + ttl: { + // We set the stale and the expire age to the same value, because the stale age is determined by the unstable_cache revalidation. + defaultStaleAge: (process.env.REDIS_URL && Number(process.env.REDIS_DEFAULT_TTL)) || 86400, + estimateExpireAge: (staleAge) => staleAge, + }, }; });