Creates a throttling cache middleware.
Successful GET responses are cached for a configurable TTL (throttle). Subsequent requests with the same key within the TTL receive a cloned cached response without hitting the network.
throttle
Cache configuration.
A Middleware that caches responses.
// 2-second TTL with cache invalidation on mutations:const client = createClient(api, { middlewares: [throttlingCache({ throttle: 2000, invalidate: (_url, _init, meta) => { if (meta && meta.method !== 'GET') return `GET@${meta.collectionPath}`; return null; }, })],}); Copy
// 2-second TTL with cache invalidation on mutations:const client = createClient(api, { middlewares: [throttlingCache({ throttle: 2000, invalidate: (_url, _init, meta) => { if (meta && meta.method !== 'GET') return `GET@${meta.collectionPath}`; return null; }, })],});
Creates a throttling cache middleware.
Successful GET responses are cached for a configurable TTL (
throttle). Subsequent requests with the same key within the TTL receive a cloned cached response without hitting the network.