Comments (4)
@dkichler Thanks for your pr, I had merged it and made a bit refactoringπ. See 6134b7a
and https://github.com/kuitos/axios-extensions/#more-advanced
Now there are two ways that can meet your requirement.
- define a default cache manually when constructing
const defaultCache = new LRUCache({ maxAge: cacheAge });
const http = axios.create({
baseURL: '/',
headers: { 'Cache-Control': 'no-cache' },
adapter:cacheAdapterEnhancer(axios.defaults.adapter, true, 'cache', defaultCache)
});
- specify the cache instance other than the default cache when request made
const cache = new LRUCache({ maxAge: cacheAge });
http.get('/users', { cache });
wish that will solve your problem!
And thanks for your advice and pr again!π
from axios-extensions.
Thanks for your advice and nice pr!π
I will check the code and consider the necessity on weekends.
from axios-extensions.
released v2.0.0
from axios-extensions.
Very nice, your improvement is far cleaner - does not break the existing API, and allows explicit control over the cache through dependency injection.
from axios-extensions.
Related Issues (20)
- Migrate LRUCache to v9.x.x
- axios 1.x has changed axios.defaults.adapter HOT 7
- Source maps reference .ts files
- axios 1.5.0 not compatible HOT 1
- Cannot find "./lib/helpers/buildURL" HOT 4
- version 3.1.3 is not es5 compatible because of lru-cache 5.1.1 HOT 3
- Ability to check if response is served from cache
- Invalidate All Cache HOT 3
- Is it possible to save cache in localstorage? HOT 1
- maxAge or throttleAdapterEnhancer HOT 1
- Is it possible to get the network request time that is cached?
- Doesn't work in Vite HOT 1
- ReferenceError: process is not defined HOT 1
- Is it possible to check if request is cached using axios response HOT 1
- Upgrade to LRUCache v7
- Missing source files for sourcemaps? HOT 3
- Warning from deprecated / renamed method in LRUCache HOT 7
- Axios cache just stopped working with today's update - How to solve? HOT 2
- About throttleAdapterEnhancer HOT 2
- Missing "./lib/helpers/buildURL" export in "axios" package HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axios-extensions.