diff --git a/docs/src/config/request-specifics.md b/docs/src/config/request-specifics.md index 7c57dad..8fcb8e4 100644 --- a/docs/src/config/request-specifics.md +++ b/docs/src/config/request-specifics.md @@ -30,7 +30,7 @@ or a custom one provided by [`config.id`](./request-specifics.md#id) -- Type: `false` or `Partial>`. +- Type: `Partial>`. - 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. diff --git a/src/cache/axios.ts b/src/cache/axios.ts index 8f2a20b..795effb 100644 --- a/src/cache/axios.ts +++ b/src/cache/axios.ts @@ -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 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> | DeprecatedFalse; + cache?: Partial> | false; } /** Cached version of type {@link InternalAxiosRequestConfig} */ diff --git a/src/interceptors/request.ts b/src/interceptors/request.ts index 00483c1..65743cc 100644 --- a/src/interceptors/request.ts +++ b/src/interceptors/request.ts @@ -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 }); }