mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2025-12-08 17:36:16 +00:00
125 lines
9.9 KiB
Plaintext
125 lines
9.9 KiB
Plaintext
flowchart TB
|
|
Title[<b>Debug Messages Guide</b><br/>Understanding axios-cache-interceptor debug output]
|
|
|
|
Title --> ReqSection[<b>REQUEST INTERCEPTOR MESSAGES</b>]
|
|
Title --> ResSection[<b>RESPONSE INTERCEPTOR MESSAGES</b>]
|
|
Title --> ErrSection[<b>ERROR INTERCEPTOR MESSAGES</b>]
|
|
|
|
ReqSection --> Msg1["'Ignoring cache because config.cache === false'"]
|
|
Msg1 --> Exp1[<b>Meaning:</b> Caching is disabled for this request<br/><b>Action:</b> Request proceeds normally without caching<br/><b>Reason:</b> config.cache was explicitly set to false]
|
|
|
|
ReqSection --> Msg2["'Ignored because url matches ignoreUrls'"]
|
|
Msg2 --> Exp2[<b>Meaning:</b> URL is blacklisted from caching<br/><b>Action:</b> Request proceeds without caching<br/><b>Reason:</b> URL matches a pattern in cachePredicate.ignoreUrls]
|
|
|
|
ReqSection --> Msg3["'Cached because url matches allowUrls'"]
|
|
Msg3 --> Exp3[<b>Meaning:</b> URL is whitelisted for caching<br/><b>Action:</b> Continue with cache logic<br/><b>Reason:</b> URL matches a pattern in cachePredicate.allowUrls]
|
|
|
|
ReqSection --> Msg4["'Ignored because url does not match any allowUrls'"]
|
|
Msg4 --> Exp4[<b>Meaning:</b> URL not in whitelist when whitelist is defined<br/><b>Action:</b> Request proceeds without caching<br/><b>Reason:</b> allowUrls is configured but URL doesn't match any pattern]
|
|
|
|
ReqSection --> Msg5["'Ignored because method not in cache.methods'"]
|
|
Msg5 --> Exp5[<b>Meaning:</b> HTTP method not cacheable<br/><b>Action:</b> Request proceeds without caching<br/><b>Reason:</b> Method like POST, PUT, DELETE not in cache.methods array<br/><b>Note:</b> Default methods are GET and HEAD only]
|
|
|
|
ReqSection --> Msg6["'Waiting list had a deferred for this key, waiting for it to finish'"]
|
|
Msg6 --> Exp6[<b>Meaning:</b> Another request for same resource is in progress<br/><b>Action:</b> Wait for that request to complete<br/><b>Reason:</b> Prevents duplicate requests for same resource<br/><b>Result:</b> Will use result from the first request]
|
|
|
|
ReqSection --> Msg7["'Updated stale request'"]
|
|
Msg7 --> Exp7[<b>Meaning:</b> Added conditional headers to request<br/><b>Action:</b> Request sent with If-None-Match or If-Modified-Since<br/><b>Reason:</b> Have stale data, asking server if it changed<br/><b>Result:</b> May receive 304 Not Modified if unchanged]
|
|
|
|
ReqSection --> Msg8["'Sending request, waiting for response'"]
|
|
Msg8 --> Exp8[<b>Meaning:</b> Making actual HTTP request to server<br/><b>Action:</b> Request proceeds to adapter<br/><b>Reason:</b> No fresh cache available or override requested<br/><b>States:</b> Cache state was empty, stale, or must-revalidate]
|
|
|
|
ReqSection --> Msg9["'Detected concurrent request, waiting for it to finish'"]
|
|
Msg9 --> Exp9[<b>Meaning:</b> Another request for same key is loading<br/><b>Action:</b> Wait for other request's deferred promise<br/><b>Reason:</b> Optimizes to avoid duplicate network requests<br/><b>Result:</b> Will share the result once available]
|
|
|
|
ReqSection --> Msg10["'Deferred rejected, requesting again'"]
|
|
Msg10 --> Exp10[<b>Meaning:</b> The concurrent request failed<br/><b>Action:</b> Make a new request instead of using failed result<br/><b>Reason:</b> Cannot rely on failed request's result<br/><b>Note:</b> This is a retry mechanism]
|
|
|
|
ReqSection --> Msg11["'Deferred resolved, but no data was found, requesting again'"]
|
|
Msg11 --> Exp11[<b>Meaning:</b> Cache mismatch - deferred resolved but no data in storage<br/><b>Action:</b> Make a new request<br/><b>Reason:</b> Unexpected state, likely storage was cleared mid-request<br/><b>Note:</b> This should rarely happen]
|
|
|
|
ReqSection --> Msg12["'Returning cached response'"]
|
|
Msg12 --> Exp12[<b>Meaning:</b> Returning data from cache without HTTP request<br/><b>Action:</b> Use cached adapter instead of real adapter<br/><b>Reason:</b> Have fresh cached data<br/><b>Result:</b> No network request made, instant response]
|
|
|
|
ResSection --> Msg13["'Returned cached response'"]
|
|
Msg13 --> Exp13[<b>Meaning:</b> Response came from cache<br/><b>Action:</b> Return immediately without processing<br/><b>Reason:</b> response.cached === true<br/><b>Note:</b> Already processed in request interceptor]
|
|
|
|
ResSection --> Msg14["'Response with config.cache falsy'"]
|
|
Msg14 --> Exp14[<b>Meaning:</b> Response has no cache config<br/><b>Action:</b> Return without caching<br/><b>Reason:</b> Cache was disabled or not configured<br/><b>Note:</b> Should rarely happen in normal flow]
|
|
|
|
ResSection --> Msg15["'Ignored because method not in cache.methods'"]
|
|
Msg15 --> Exp15[<b>Meaning:</b> Response from uncacheable method<br/><b>Action:</b> Return without caching<br/><b>Reason:</b> Method not configured for caching<br/><b>Note:</b> Duplicate check from request interceptor]
|
|
|
|
ResSection --> Msg16["'Response not cached and storage isn't loading'"]
|
|
Msg16 --> Exp16[<b>Meaning:</b> Unexpected state mismatch<br/><b>Action:</b> Return response without caching<br/><b>Reason:</b> Storage state should be 'loading' but isn't<br/><b>Note:</b> May indicate request interceptor was bypassed]
|
|
|
|
ResSection --> Msg17["'Cache predicate rejected this response'"]
|
|
Msg17 --> Exp17[<b>Meaning:</b> Response doesn't meet caching criteria<br/><b>Action:</b> Reject cache and remove from storage<br/><b>Reason:</b> Failed statusCheck, responseMatch, or containsHeaders<br/><b>Example:</b> Status code not in allowed list 200, 203, 300, etc.]
|
|
|
|
ResSection --> Msg18["'Cache header interpreted as dont cache'"]
|
|
Msg18 --> Exp18[<b>Meaning:</b> Server headers forbid caching<br/><b>Action:</b> Reject cache and remove from storage<br/><b>Reason:</b> Cache-Control: no-cache/no-store or private on server<br/><b>Headers:</b> Server sent explicit cache prevention directives]
|
|
|
|
ResSection --> Msg19["'Useful response configuration found'"]
|
|
Msg19 --> Exp19[<b>Meaning:</b> Successfully calculated cache TTL and config<br/><b>Action:</b> Proceeding to save to storage<br/><b>Reason:</b> All validations passed<br/><b>Info:</b> Contains cacheConfig and cacheResponse data]
|
|
|
|
ResSection --> Msg20["'Found waiting deferred(s) and resolved them'"]
|
|
Msg20 --> Exp20[<b>Meaning:</b> Resolving other waiting requests<br/><b>Action:</b> Notify concurrent requests that data is ready<br/><b>Reason:</b> Multiple requests were waiting for this response<br/><b>Result:</b> All waiting requests now get the cached data]
|
|
|
|
ResSection --> Msg21["'Response cached'"]
|
|
Msg21 --> Exp21[<b>Meaning:</b> Successfully saved response to cache<br/><b>Action:</b> Data now available for future requests<br/><b>Reason:</b> All caching conditions met<br/><b>State:</b> Storage state is now 'cached']
|
|
|
|
ErrSection --> Msg22["'FATAL: Received non-axios error in rejected interceptor'"]
|
|
Msg22 --> Exp22[<b>Meaning:</b> Unknown error type received<br/><b>Action:</b> Re-throw error, cannot handle<br/><b>Reason:</b> Error is not from Axios<br/><b>Impact:</b> May leave storage in loading state]
|
|
|
|
ErrSection --> Msg23["'Web request returned error but cache handling not enabled'"]
|
|
Msg23 --> Exp23[<b>Meaning:</b> Error occurred but caching is disabled<br/><b>Action:</b> Re-throw error<br/><b>Reason:</b> config.cache or config.id missing<br/><b>Note:</b> Normal error flow without cache]
|
|
|
|
ErrSection --> Msg24["'Caught an error in the request interceptor'"]
|
|
Msg24 --> Exp24[<b>Meaning:</b> Error but storage state is unexpected<br/><b>Action:</b> Clean up and re-throw<br/><b>Reason:</b> State not 'loading' or previous not 'stale'<br/><b>Note:</b> Cannot use staleIfError logic]
|
|
|
|
ErrSection --> Msg25["'Found cache if stale config for rejected response'"]
|
|
Msg25 --> Exp25[<b>Meaning:</b> Evaluating staleIfError option<br/><b>Action:</b> Check if can return stale data instead of error<br/><b>Reason:</b> config.staleIfError is configured<br/><b>Next:</b> Evaluate if stale data is still usable]
|
|
|
|
ErrSection --> Msg26["'Found waiting deferred(s) and resolved them'"]
|
|
Msg26 --> Exp26[<b>Meaning:</b> Resolving waiting requests with stale data<br/><b>Action:</b> Return stale cached data to all waiting requests<br/><b>Reason:</b> staleIfError allowed using stale data<br/><b>Result:</b> Error avoided by using cached data]
|
|
|
|
ErrSection --> Msg27["'staleIfError resolved this response with cached data'"]
|
|
Msg27 --> Exp27[<b>Meaning:</b> Returning stale data instead of error<br/><b>Action:</b> Return cached response marked as stale<br/><b>Reason:</b> Request failed but stale data acceptable<br/><b>Properties:</b> cached: true, stale: true]
|
|
|
|
ErrSection --> Msg28["'Received unknown error that could not be handled'"]
|
|
Msg28 --> Exp28[<b>Meaning:</b> Error cannot be recovered with staleIfError<br/><b>Action:</b> Reject cache and re-throw error<br/><b>Reason:</b> staleIfError not configured or expired<br/><b>Result:</b> Error propagates to caller]
|
|
|
|
style Title fill:#e1f0ff,stroke:#333,stroke-width:3px
|
|
style ReqSection fill:#d4edda,stroke:#333,stroke-width:2px
|
|
style ResSection fill:#d1ecf1,stroke:#333,stroke-width:2px
|
|
style ErrSection fill:#f8d7da,stroke:#333,stroke-width:2px
|
|
|
|
style Exp1 fill:#fff4e1
|
|
style Exp2 fill:#fff4e1
|
|
style Exp3 fill:#d1ffe1
|
|
style Exp4 fill:#fff4e1
|
|
style Exp5 fill:#fff4e1
|
|
style Exp6 fill:#e1f0ff
|
|
style Exp7 fill:#e1f0ff
|
|
style Exp8 fill:#e1f0ff
|
|
style Exp9 fill:#e1f0ff
|
|
style Exp10 fill:#ffe8d1
|
|
style Exp11 fill:#ffe8d1
|
|
style Exp12 fill:#d1ffe1
|
|
style Exp13 fill:#d1ffe1
|
|
style Exp14 fill:#fff4e1
|
|
style Exp15 fill:#fff4e1
|
|
style Exp16 fill:#ffe8d1
|
|
style Exp17 fill:#ffe1e1
|
|
style Exp18 fill:#ffe1e1
|
|
style Exp19 fill:#d1ffe1
|
|
style Exp20 fill:#e1f0ff
|
|
style Exp21 fill:#d1ffe1
|
|
style Exp22 fill:#ffe1e1
|
|
style Exp23 fill:#fff4e1
|
|
style Exp24 fill:#ffe8d1
|
|
style Exp25 fill:#e1f0ff
|
|
style Exp26 fill:#e1f0ff
|
|
style Exp27 fill:#d1ffe1
|
|
style Exp28 fill:#ffe1e1
|