Comments (1)
Hey @paescuj is this directly impacting the performance of your app? Request and response in axios should have completely separated state from each other, that's why two finds happen.
I do not have time or a appealing reason to do such optimization this storage access should be almost irrelevant comparing to a network request which would happen always without axios-cache-interceptor
.
However, I'm happy to guide you if you wanna work on it.
Let me walk you through what is currently happening in your usecase.
- Request is made,
get()
is called in the request interceptor.
- The storage wrapper detects the storage returned an stale entry with
cached
status,set()
is called to also update this entry in the db.
axios-cache-interceptor/src/storage/build.ts
Line 131 in d4fa7d8
- Everything is loaded to wait for a network response, a
set()
call is made to update this entry in the db toloading
.
axios-cache-interceptor/src/interceptors/request.ts
Lines 92 to 95 in d4fa7d8
-
Request is sent to network, event
'Sending request, waiting for response'
is emitted. -
Response arrives, the response interceptor has no real information of what happened before and has no state connection to the request interceptor, so another
get()
is performed.
- Response is processed and before returning, a
set()
is called to insert the response gotten from network.
However the use case you presented here probably have the highest ratio of db calls per request. Cached requests should have only a single get()
.
from axios-cache-interceptor.
Related Issues (20)
- Question: when exactly is `if-modified-since` sent? HOT 4
- Bug: staleIfError + overrides don't seem to work on blocked requests HOT 7
- Is there an option to make a request that will cross out the cashe? HOT 1
- Bug: hydrate config
- Bug: Setting an independent TTL for an individual request does not work HOT 2
- Bug: Error: setupCache() should be called only once HOT 2
- [Question] Considering 'Accept' header for generating request ID HOT 1
- Bug: TypeError: 0, _axiosCacheInterceptor.setupCache is not a function (it is undefined) HOT 3
- Bug: error TS2345: Argument of type 'AxiosStatic' is not assignable to parameter of type 'AxiosInstance' HOT 12
- Bug: URLSearchParams serialize to empty object causing to produce same cache key for different query parameters. HOT 2
- Bug: error during build phase
- Question: does it works for streaming requests ? HOT 2
- Bug: error during build phase HOT 4
- Question: How to do a proper offline-mode HOT 2
- Feature requests: Stats of storage, memory size HOT 1
- Bug: CORS Error using setupCache HOT 1
- Cache collisions detected with defaultKeyGenerator, at the level of 100K cache keys HOT 1
- Feature request: Invalidate all HOT 1
- Bug: must-revalidate cache-control makes entries to be cleaned from storage, while it's eTag could still be used for the If-None-Match header HOT 4
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-cache-interceptor.