Skip to content

Conversation

@logan-stytch
Copy link
Contributor

This PR implements background refresh for both JWKS and RBAC policy caches to reduce latency. '

The RBAC PolicyCache now uses a 1-hour TTL (up from 5 minutes) with coroutine-based background refresh that proactively updates the policy every hour. We're standardizing on 1-hour TTL for our caches across the Stytch SDKs.

For JWKS caching, a new JwksCache factory helper was created that configures jose4j's HttpsJwks with a 1-hour cache duration and 5-minute refresh threshold for automatic background refresh.

@logan-stytch logan-stytch requested a review from a team as a code owner November 7, 2025 20:59
Copy link
Contributor

@jhaven-stytch jhaven-stytch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say my notes only need addressing IF you anticipate the refresh job being cancelled/cancellable. From what I can tell, since we use a result class for the network call, the job shouldn't get cancelled from any failures, so isActive should always be true, but...

@logan-stytch logan-stytch merged commit 25ca374 into main Nov 7, 2025
3 checks passed
@logan-stytch logan-stytch deleted the logan/back-5074 branch November 7, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants