Skip to content

Commit 3ef86a0

Browse files
committed
document caching behaviour
1 parent d255a4b commit 3ef86a0

File tree

1 file changed

+28
-0
lines changed
  • docs-js/features/connectivity

1 file changed

+28
-0
lines changed

docs-js/features/connectivity/ias.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,31 @@ The destination includes `mtlsKeyPair` with x509 credentials from the IAS servic
198198
Use these credentials for mTLS communication with the provider system.
199199

200200
:::
201+
202+
### Token Caching
203+
204+
IAS tokens are cached automatically to improve performance and reduce load on the IAS broker.
205+
The cache is resource-aware, meaning tokens for different provider dependencies are cached separately.
206+
207+
The cache key includes the tenant ID, client ID, and the normalized resource parameter.
208+
This prevents incorrect token reuse across different provider dependencies.
209+
210+
```typescript
211+
const token1 = await serviceToken('my-identity-service', {
212+
iasOptions: { resource: { name: 'backend-api' } }
213+
});
214+
215+
const token2 = await serviceToken('my-identity-service', {
216+
iasOptions: { resource: { name: 'backend-api' } }
217+
});
218+
```
219+
220+
In the example above, the second call returns the cached token from the first call.
221+
A call with a different resource would fetch a new token from the IAS broker.
222+
223+
Tokens are cached until they expire.
224+
To bypass the cache, set `useCache: false` in the options.
225+
Multiple resources in an array create a single cache entry, regardless of order.
226+
227+
In multi-tenant scenarios, each tenant gets separate cache entries.
228+
The `appTid` parameter affects the cache key.

0 commit comments

Comments
 (0)