Axios-cacher is a lightweight caching wrapper for Axios that stores API response data in memory with configurable expiration (maxAge) and manual cache invalidation via user keys. The current stable version is 1.1.4, released in 2021 with no notable update cadence. It provides a setup function returning both a cached axios client and an invalidation helper. Unlike generic caching solutions, it ties cache entries to unique user keys for targeted invalidation. The package is minimal (no persistence, no external dependencies beyond axios) and targets Node.js environments.
npm install axios-cacherNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates setup with caching, making a cached GET request, and manually invalidating the cache entry.
Ensure invalidate function is async or returns a promise.
Use a persistent cache adapter if needed (not built-in).
Create a .d.ts file: declare module 'axios-cacher' { function setup(config: any): { axiosClient: any; invalidateThis: (key: string) => Promise<void> }; export default setup; }Always include userKey in the request config object for each call you want to cache/invalidate.
Ensure setup() is called with a valid config object containing baseURL and cache.maxAge.
Use const setup = require('axios-cacher').default; or use ES import syntax.Invalidate cache or increase maxAge with error handling to retry fresh requests on failure.