lisaogren / axios-cache-adapter

Caching adapter for axios. Store request results in a configurable store to prevent unneeded network requests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throttle calls only if url not in cache

jodoox opened this issue · comments

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?