Merged
Size
S
Change Breakdown
Performance80%
Bug Fix20%
#3388feat(webapp): add 60s/60s SWR cache to getEntitlement

Trigger latency reduced with entitlement caching

Trigger execution should be significantly faster now that organization entitlement checks are cached locally. A new stale-while-revalidate strategy eliminates synchronous round trips to the billing service.

Every trigger execution previously required a synchronous HTTP round trip to the billing service to verify organization entitlements. This introduced network latency directly into the execution pipeline.

Triggers now execute much faster. Organization entitlements are cached locally using a 60-second stale-while-revalidate strategy. This eliminates the synchronous network bottleneck while keeping plan data sufficiently fresh. If the billing service experiences an outage, triggers automatically fail open to ensure continued execution. These transient permissive states are deliberately kept out of the cache, ensuring legitimate access restrictions are not permanently overwritten during temporary downtime.

The caching optimizations are applied directly within the core platform services, with best-effort invalidation instantly applying any plan upgrades or downgrades.

View Original GitHub Description

Wraps getEntitlement in platform.v3.server.ts with the existing platformCache (LRU memory + Redis) under a new entitlement namespace. Eliminates a synchronous billing-service HTTP round trip on every trigger.

Cache config: 60s fresh / 60s stale SWR. Cache key is the organization id. Errors are caught inside the loader and return the existing permissive { hasAccess: true } fallback, which is also cached to prevent thundering-herd on billing outages.

Trade-off: plan upgrade/downgrade is now visible after up to ~120s worst-case (60s fresh + 60s stale revalidation). Acceptable since the existing limits and usage namespaces use 5min/10min, and the defensive hasAccess: true fallback already exists.

© 2026 · via Gitpulse