Skip to content

Commit 834a021

Browse files
committed
fix(webapp): correct entitlement cache stale TTL
The stale parameter on @unkey/cache Namespace is the TOTAL ttl, not an additional window beyond fresh. Setting fresh: 60_000 and stale: 60_000 gave a fresh-only entry that expired entirely at 60s with no SWR window. Setting stale: 120_000 yields the intended behavior: fresh 0-60s, stale-revalidate 60-120s. Verified locally with agentcrumbs by running through cache miss, fresh hit, stale revalidate, and stale-with-failed-bg-revalidate scenarios against a live billing server.
1 parent 312c91b commit 834a021

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

apps/webapp/app/services/platform.v3.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ function initializePlatformCache() {
7373
}),
7474
entitlement: new Namespace<ReportUsageResult>(ctx, {
7575
stores: [memory, redisCacheStore],
76-
fresh: 60_000, // 60 seconds
77-
stale: 60_000, // 60 seconds
76+
fresh: 60_000, // serve without revalidation for 60s
77+
stale: 120_000, // total TTL — fresh 0-60s, stale-revalidate 60-120s
7878
}),
7979
});
8080

0 commit comments

Comments
 (0)