axios-cache-adapter and axios-cache-interceptor are both libraries designed to add HTTP caching capabilities to Axios requests in JavaScript applications. They enable developers to avoid redundant network calls by storing and reusing responses based on configurable cache strategies, improving performance and reducing server load. Both integrate directly with Axios but differ significantly in architecture, API design, and maintenance status.
Both axios-cache-adapter and axios-cache-interceptor aim to solve the same core problem: caching HTTP responses in Axios-based applications to reduce redundant network requests, improve perceived performance, and lower backend load. However, they take fundamentally different approaches — one is a legacy solution built on Axios adapters, while the other is a modern, actively maintained library leveraging Axios interceptors. Let’s break down what this means in practice.
axios-cache-adapter is officially deprecated. Its npm page and GitHub repository clearly state: "This project is deprecated. Please use axios-cache-interceptor instead." No new features are being added, and only critical fixes might be considered. Using it in new projects introduces long-term risk.
axios-cache-interceptor is the recommended successor, actively developed and aligned with current Axios versions. It’s designed to work seamlessly with Axios v0.27 and above, including support for modern features like request aborting and proper TypeScript definitions.
💡 Bottom line: For any new project, start with
axios-cache-interceptor. Only consideraxios-cache-adapterif you’re stuck maintaining old code that hasn’t been migrated yet.
Axios supports two extension points: adapters (which handle the actual HTTP transport) and interceptors (which hook into request/response flows). The two packages use these differently.
axios-cache-adapter replaces Axios’s default adapter entirely:
// axios-cache-adapter: replaces the adapter
import axios from 'axios';
import { setupCache } from 'axios-cache-adapter';
const cache = setupCache({ maxAge: 15 * 60 * 1000 }); // 15 minutes
const api = axios.create({
adapter: cache.adapter
});
const response = await api.get('/users');
This approach works but tightly couples caching logic to the transport layer, making it harder to compose with other adapters (e.g., for mocking or custom backends).
axios-cache-interceptor uses standard Axios interceptors, which plug into the existing request/response pipeline without replacing core behavior:
// axios-cache-interceptor: uses interceptors
import axios from 'axios';
import { setupCache } from 'axios-cache-interceptor';
const api = setupCache(axios.create());
const response = await api.get('/users', {
cache: { ttl: 15 * 60 * 1000 } // 15 minutes
});
This is more flexible — you can still use custom adapters, and caching becomes just one layer in your Axios configuration stack.
How you tell each library what to cache and for how long also differs.
axios-cache-adapter relies on its own configuration object passed at instance creation or per-request:
// axios-cache-adapter: custom cache config
const response = await api.get('/posts', {
cache: {
maxAge: 10000, // milliseconds
exclude: { query: false }
}
});
It doesn’t natively respect standard HTTP caching headers like Cache-Control or ETag unless you implement custom logic.
axios-cache-interceptor leans heavily into standard HTTP caching semantics. By default, it respects Cache-Control, Expires, and ETag headers from responses. You can also override with explicit TTL:
// axios-cache-interceptor: HTTP-aware + overrides
const response = await api.get('/posts', {
cache: {
ttl: 10000, // fallback if no HTTP headers
interpretHeader: true // default: uses Cache-Control
}
});
This means your frontend cache can automatically align with your backend’s caching policy — a big win for consistency.
Both libraries support manual cache clearing, but their APIs differ.
axios-cache-adapter exposes a global cache object with methods like del():
// axios-cache-adapter: manual invalidation
await api.get('/user/123');
// Later...
cache.del('/user/123'); // removes cached entry
axios-cache-interceptor provides more granular control via the axios instance itself:
// axios-cache-interceptor: instance-based invalidation
await api.get('/user/123');
// Later...
api.storage.remove('/user/123'); // or use api.cache.delete()
Additionally, axios-cache-interceptor supports automatic cache updates using stale-while-revalidate strategies and conditional requests (If-None-Match) when ETags are present — reducing stale data without blocking UI updates.
axios-cache-adapter offers basic logging via the debug option, but debugging cache hits/misses often requires inspecting internal structures.
axios-cache-interceptor includes built-in debug tools:
const api = setupCache(axios.create(), {
debug: true // logs cache decisions to console
});
It also exposes clear metadata on responses:
const res = await api.get('/data');
console.log(res.cached); // true | false | 'stale'
This makes it far easier to verify caching behavior during development.
You need to fetch user stats every 30 seconds but avoid hammering the server if data hasn’t changed.
axios-cache-interceptorstale-while-revalidate and ETag-based conditional requests out of the box:setInterval(async () => {
const res = await api.get('/stats', {
cache: { ttl: 30_000, staleWhileRevalidate: true }
});
updateUI(res.data);
}, 30_000);
Your old app uses axios-cache-adapter, and you can’t rewrite everything at once.
axios-cache-adapter during incremental migration| Feature | axios-cache-adapter | axios-cache-interceptor |
|---|---|---|
| Status | ❌ Deprecated (do not use in new projects) | ✅ Actively maintained |
| Integration Method | Replaces Axios adapter | Uses Axios interceptors |
| HTTP Header Support | Limited (requires custom logic) | Full Cache-Control, ETag, Expires |
| Cache Metadata | Minimal | Rich (res.cached, debug logs) |
| Modern Axios Support | Uncertain (last tested on older versions) | Built for Axios v0.27+ |
| Stale-While-Revalidate | Not supported | ✅ Supported |
If you’re starting a new frontend project that uses Axios and needs caching:
→ Use axios-cache-interceptor. It’s the official, modern, and sustainable choice.
If you’re working on an existing codebase using axios-cache-adapter:
→ Plan a migration to axios-cache-interceptor. The effort pays off in maintainability, correctness, and alignment with web standards.
Caching is hard to get right — using a well-maintained, HTTP-compliant library reduces bugs and keeps your app fast without reinventing the wheel.
Choose axios-cache-interceptor for all new projects requiring Axios caching. It is actively maintained, built specifically for modern Axios (v0.27+), uses Axios interceptors instead of adapters for cleaner integration, and offers more flexible cache control through standard HTTP headers and fine-grained configuration options.
Choose axios-cache-adapter only if you are maintaining a legacy codebase that already depends on it. The package is officially deprecated as of 2023, no longer accepts new features, and recommends migration to axios-cache-interceptor. It should not be used in new projects due to lack of active support and compatibility risks with future Axios versions.
Using this package? Please consider donating to support my open source work ❤️
Help axios-cache-interceptor grow! Star and share this amazing repository with your friends and co-workers!
Cache interceptor for axios made with developers and performance in mind.
Axios Cache Interceptor is, as it name says, a interceptor for axios to handle caching. It was created to help developers call axios multiple times without having to worry about overloading the network or coding himself a simple and buggy cache system.
import Axios from 'axios';
import { setupCache } from 'axios-cache-interceptor';
const instance = Axios.create();
const axios = setupCache(instance);
const req1 = axios.get('https://arthur.place/');
const req2 = axios.get('https://arthur.place/');
const [res1, res2] = await Promise.all([req1, req2]);
res1.cached; // false
res2.cached; // true
Licensed under the MIT. See LICENSE for more informations.