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) => { if (init.method !== 'GET') return `GET@${url}`; return null; }, })],}); Copy
// 2-second TTL with cache invalidation on mutations:const client = createClient(api, { middlewares: [throttlingCache({ throttle: 2000, invalidate: (url, init) => { if (init.method !== 'GET') return `GET@${url}`; 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.