mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2025-12-08 17:36:16 +00:00
docs: Add comment explaining why conditional headers are skipped when override is true
Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
This commit is contained in:
parent
23cdaa2350
commit
ffb02a8866
@ -182,6 +182,9 @@ export function defaultRequestInterceptor(axios: AxiosCacheInstance): RequestInt
|
||||
config
|
||||
);
|
||||
|
||||
// Skip adding conditional headers (If-None-Match, If-Modified-Since) when override is true.
|
||||
// The override option is meant to bypass cache and get fresh data, not revalidate existing cache.
|
||||
// Adding conditional headers would cause the server to return 304 Not Modified instead of fresh data.
|
||||
if ((cache.state === 'stale' || cache.state === 'must-revalidate') && !overrideCache) {
|
||||
updateStaleRequest(cache, config as ConfigWithCache<unknown>);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user