Remove deprecation warnings from docs, keep cache: false for backward compatibility

Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-08 15:23:30 +00:00
parent 636596c05c
commit 4287dce5b3
3 changed files with 10 additions and 29 deletions

View File

@ -30,7 +30,7 @@ or a custom one provided by [`config.id`](./request-specifics.md#id)
<Badge text="optional" type="warning"/>
- Type: `false` or `Partial<CacheProperties<R, D>>`.
- Type: `Partial<CacheProperties<R, D>>`.
- Default: `{}` _(Inherits from global configuration)_
::: tip
@ -43,26 +43,15 @@ configuration
The cache option available through the request config is where all the cache customization
happens.
You can pass an object with cache properties to customize cache behavior, or set it to
`false` to disable caching for this request.
You can pass an object with cache properties to customize cache behavior.
::: warning DEPRECATED
Setting `cache: false` is deprecated. Please use `cache: { enabled: false }` instead.
:::
This does not mean that the cache will be excluded from the storage, in which case, you
can do that by deleting the storage entry:
To disable caching for a specific request, use `cache: { enabled: false }`:
```ts
// Make a request with cache disabled (new way - recommended).
// Make a request with cache disabled
const { id: requestId } = await axios.get('url', { cache: { enabled: false } });
// Make a request with cache disabled (old way - deprecated).
const { id: requestId } = await axios.get('url', { cache: false });
// Delete the cache entry for this request.
// Delete the cache entry for this request if needed
await axios.storage.remove(requestId);
```
@ -75,8 +64,7 @@ await axios.storage.remove(requestId);
Whether the cache is enabled for this request.
When set to `false`, the cache will be completely disabled for this request, similar to
setting `cache: false` in the request config.
When set to `false`, the cache will be completely disabled for this request.
This is useful for **opt-in cache** scenarios where you want to disable cache globally
but enable it for specific requests.

13
src/cache/axios.ts vendored
View File

@ -8,13 +8,6 @@ import type {
} from 'axios';
import type { CacheInstance, CacheProperties } from './cache.js';
/**
* Deprecated type for `cache: false`. Use `cache: { enabled: false }` instead.
*
* @deprecated Setting `cache: false` is deprecated. Use `cache: { enabled: false }` instead.
*/
type DeprecatedFalse = false;
/**
* A slightly changed than the original axios response. Containing information about the
* cache and other needed properties.
@ -88,15 +81,15 @@ export interface CacheRequestConfig<R = any, D = any> extends AxiosRequestConfig
*
* You can pass an object with cache properties to customize cache behavior.
*
* Setting this to `false` will disable the cache for this request.
* **Note:** `cache: false` is deprecated. Use `cache: { enabled: false }` instead.
* **Note:** Setting `cache: false` is still supported for backward compatibility, but
* will be removed in the next major release. Use `cache: { enabled: false }` instead.
*
* This does not mean that the current cache will be excluded from the storage.
*
* @default 'inherits from global configuration'
* @see https://axios-cache-interceptor.js.org/config/response-object#cache
*/
cache?: Partial<CacheProperties<R, D>> | DeprecatedFalse;
cache?: Partial<CacheProperties<R, D>> | false;
}
/** Cached version of type {@link InternalAxiosRequestConfig} */

View File

@ -19,7 +19,7 @@ export function defaultRequestInterceptor(axios: AxiosCacheInstance): RequestInt
if (__ACI_DEV__) {
axios.debug({
id: config.id,
msg: 'Ignoring cache because config.cache === false (deprecated, use cache.enabled = false)',
msg: 'Ignoring cache because config.cache === false',
data: config
});
}