A cache interceptor for Axios that transparently caches HTTP responses in memory (or custom storage) to reduce network requests. Version 1.12.0, actively maintained with weekly releases. Supports per-request TTL, cache invalidation, response cloning, and custom storage backends like localStorage. Ships TypeScript definitions. Notable differentiators: works as an Axios interceptor (not a wrapper), provides cached property on responses, and supports fine-grained cache control per request. Requires Axios 1.x as a peer dependency.
npm install axios-cache-interceptorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup with custom storage and TTL, default memory storage, and how to check if response was cached via the `.cached` property.
Create an instance with axios.create() and pass it to setupCache.
Use buildStorage() or implement the Storage interface (find, set, remove methods).
Pass cache config as an object: setupCache(instance, { cache: { ttl: 60000 } }) or per request: axios.get(url, { cache: { ttl: 30000 } })Call setupCache before adding other interceptors, or use the `interceptor` option to set explicit order.
Always use the instance returned by setupCache for all requests that need caching.
Set `interpretHeader: true` in cache options to use server-side cache headers, or set an appropriate TTL.
Use `const { setupCache } = require('axios-cache-interceptor');` or use ESM import.Create an instance: const instance = axios.create(); then call setupCache(instance).
Ensure your storage object has all three methods: find(key), set(key, value), remove(key). Use buildStorage() to create one.
Use the instance returned by setupCache for requests: `const cachedAxios = setupCache(instance); cachedAxios.get(...)`.