Throttle calls only if url not in cache
jodoox opened this issue · 0 comments
jodoox commented
Ideally I'd want to throttle my requests that are not present in the cache (but serve them immediately if they've already been fetched). I've put below an extract from https://github.com/kuitos/axios-extensions that gives an idea of what I'm looking for
const http = axios.create({
baseURL: '/',
headers: { 'Cache-Control': 'no-cache' },
adapter: throttleAdapterEnhancer(cacheAdapterEnhancer(axios.defaults.adapter))
});
It seems like this cannot be done with the adapter returned by setupCache
, given that it will try to find the query in the cache and then try to fetch via network (which allows to fallback on the stale data from the cache)
Is this somehow possible with axios-cache-adapter
?