Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Throttle calls only if url not in cache #268

Open
jodoox opened this issue Apr 8, 2022 · 0 comments
Open

Throttle calls only if url not in cache #268

jodoox opened this issue Apr 8, 2022 · 0 comments

Comments

@jodoox
Copy link

jodoox commented Apr 8, 2022

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?

@jodoox jodoox changed the title Throttle calls if url not in cache Throttle calls only if url not in cache Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant