Skip to content

fix: invalidate gateway cache on secret and rule mutations - #117

Merged
guyb1 merged 1 commit into
mainfrom
fix/cache-invalidation-on-mutation
Mar 26, 2026
Merged

fix: invalidate gateway cache on secret and rule mutations#117
guyb1 merged 1 commit into
mainfrom
fix/cache-invalidation-on-mutation

Conversation

@guyb1

@guyb1 guyb1 commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Credentials added via the dashboard were not immediately available to agents due to the gateway's 60-second CONNECT response cache. This adds cache invalidation so changes take effect instantly.

Changes

Gateway (Rust):

  • Add del_by_prefix method to CacheStore trait (both InMemory and Redis implementations)
  • Include account_id in cache key format: connect:{account_id}:{token}:{host}
  • Add POST /api/cache/invalidate endpoint (authenticated, scoped to caller's account)

Web app (TypeScript):

  • Add useInvalidateGatewayCache hook for client-side cache busting
  • Call it after every secret create/update/delete, rule create/update/delete/toggle, agent token regeneration, agent deletion, and agent secret assignment changes

How it works

  1. User mutates a secret/rule/agent in the dashboard
  2. Server action saves to DB
  3. Client fires POST /api/cache/invalidate to the gateway (fire-and-forget)
  4. Gateway clears all cached CONNECT responses for that account
  5. Next agent request hits the DB and gets fresh data

Fixes #116

Add POST /api/cache/invalidate endpoint to the gateway that clears
cached CONNECT responses for the authenticated account. Include
account_id in cache keys to enable prefix-based invalidation.

Web app calls the endpoint after every secret, rule, and agent
mutation so agents pick up changes immediately instead of waiting
for the 60-second cache TTL.

Fixes #116
@guyb1
guyb1 merged commit 9966c98 into main Mar 26, 2026
1 check passed
@guyb1
guyb1 deleted the fix/cache-invalidation-on-mutation branch March 26, 2026 19:03
@guyb1 guyb1 mentioned this pull request Mar 26, 2026
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.

Newly added credentials not available immediately — cache delay on add

1 participant