Skip to content

Cache validated sessions to reduce WorkOS API calls - #303

Merged
bokelley merged 3 commits into
mainfrom
bokelley/fix-auth-rate-limit
Dec 12, 2025
Merged

bokelley merged 3 commits into
mainfrom
bokelley/fix-auth-rate-limit

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Implement in-memory session validation cache with 60-second TTL to prevent rate limiting issues from repeated WorkOS API calls. The dashboard was triggering 15+ WorkOS API calls per page load because session.refresh() was being called multiple times for each authenticated request.

Changes

  • Added session cache with 60-second TTL (reduces API calls while catching revocations)
  • Cache is invalidated on logout to ensure immediate session revocation
  • Background cleanup runs every 5 minutes to remove expired entries
  • Applied to both requireAuth and optionalAuth middleware

Test plan

  • TypeScript compiles
  • All tests pass
  • Manual test: Dashboard loads with cached session after first auth

bokelley and others added 3 commits December 12, 2025 15:14
Implement in-memory session validation cache with 60-second TTL to prevent
rate limiting issues from repeated WorkOS API calls. Invalidate cache on logout
to ensure immediate revocation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

1 participant