Skip to content

Response object ​

Axios Cache Interceptor adds a few cache-related properties to the standard axios response.

id ​

  • Type: string

The Request ID used in this request.

It was either generated by the key generator or provided through config.id.

ts
const response = await axios.get('url', { id: 'my-overridden-id' });

// This request used 'my-overridden-id' instead of
// the ID the key generator would have produced
response.id === 'my-overridden-id';

cached ​

  • Type: boolean

Whether the response data came from the cache (true) or from the network (false). A 304 Not Modified revalidation also returns true, because the data comes from the existing cache entry.

TIP

This does not tell you whether the request could have been cached. Options such as cache.override make a network request even when a cached response exists.

stale ​

  • Type: boolean | undefined

true when the response was served from a stale entry, for example when cache.staleIfError returned cached data after a failed request. It is also true for requests that waited on a concurrent revalidation of a stale entry. It is false for fresh cache hits and undefined for network responses, including 304 revalidations.

Made with ❤️