A lightweight plugin that adds client-side caching for GET requests made with Axios. It wraps an Axios instance or the default Axios, caching responses in memory based on URL and optional headers. Version 0.1.0 (latest as of March 2025) is a stable release with minimal updates. Key features: configurable max cache size (default 15), TTL support, and exclusion of headers from cache keys. Unlike more comprehensive caching libraries (e.g., axios-extensions), this plugin uses explicit filter registration via regex patterns, giving precise control over which requests are cached. It is simple and focused, suitable for small to medium projects.
npm install axios-cache-pluginNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup: wrapping axios, adding a regex filter, making a cached GET request, and clearing the cache.
Always call http.__addFilter(/regex/) with a pattern that matches the URLs you want to cache.
Set excludeHeaders: true in wrapper options to ignore headers when generating cache keys.
Use only for caching GET requests. For other methods, implement a custom caching solution.
Consider migrating to axios-extensions or implementing a custom Axios adapter for caching.
Use const wrapper = require('axios-cache-plugin').default;Ensure you call __addFilter on the object returned by wrapper(axios, options).
Verify the request is GET, the URL matches the filter, and set excludeHeaders: true to ignore header variations.