Registry / devops / axios-cache-adapter-fixed

axios-cache-adapter-fixed

JSON →
library1.0.8jsnpmunverified

A caching adapter for axios that stores request results in a configurable store to prevent unnecessary network requests. Version 1.0.8, released as a fixed fork of the original axios-cache-adapter. It wraps axios to cache GET requests (configurable) using localForage or any compatible store. Key differentiators include simple setup via setupCache() or setup(), per-request cache option overrides, and TypeScript type definitions. It is a lightweight alternative to more complex caching solutions like react-query or SWR, but limited to axios-only use.

npm install axios-cache-adapter-fixed
INSTALL
IMPORT
SIG · AXIOS-CACHE-ADAPTE
A
axios-cache-adapter-fixed
devopsjavascriptv1.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

setupCache
import { setupCache } from 'axios-cache-adapter-fixed'
import setupCache from 'axios-cache-adapter-fixed'
This module uses named exports exclusively. Default import will not work.
setup
import { setup } from 'axios-cache-adapter-fixed'
const setup = require('axios-cache-adapter-fixed').setup
CommonJS require() works, but the correct named import is preferred for TypeScript.
setupCache (type)
import type { setupCache } from 'axios-cache-adapter-fixed'
import { setupCache } from 'axios-cache-adapter-fixed'
If you only need the type for setupCache, use the type import syntax to avoid emitting runtime code.

Creates an axios instance with a caching adapter that caches GET requests for 15 minutes.

import axios from 'axios'; import { setupCache } from 'axios-cache-adapter-fixed'; const cache = setupCache({ maxAge: 15 * 60 * 1000 }); const api = axios.create({ adapter: cache.adapter }); api.get('https://jsonplaceholder.typicode.com/posts/1') .then(response => { console.log('Response data:', response.data); cache.store.length().then(len => console.log('Cache store length:', len)); }) .catch(error => console.error(error));
Debug
Known issues
gotchaOnly GET requests are cached by default; other methods invalidate the cache for the URL.
fix
Modify exclude.methods in cache options to allow caching other methods, or disable cache invalidation on write.
affects: >=1.0.0
breakingThe import path changed from 'axios-cache-adapter' to 'axios-cache-adapter-fixed'. Original package is deprecated/unmaintained.
fix
Replace 'axios-cache-adapter' with 'axios-cache-adapter-fixed' in imports and package.json.
affects: >=1.0.0
gotchaPer-request cache options cannot override all instance-level settings (e.g., store, maxAge may be limited).
fix
Refer to the API documentation to see which options are overridable; test your expected behavior.
affects: >=1.0.0
gotchaThe adapter stores responses using JSON.stringify/parse; non-serializable data (e.g., Blob, Stream) will break caching.
fix
Avoid caching responses with non-serializable data, or implement a custom store that handles them.
affects: >=1.0.0
gotchaThe cache key is based on the URL only, ignoring query parameters by default (unless exclude.query is set to false).
fix
Set exclude.query: false in cache options to include query parameters in the cache key.
affects: >=1.0.0
Errors
Common errors & fixes
Error: setupCache is not a function
Incorrect import style: using default import instead of named import.
fix
Use import { setupCache } from 'axios-cache-adapter-fixed'.
Module not found: Can't resolve 'axios-cache-adapter-fixed'
Package not installed or typo in package name.
fix
Run 'npm install axios-cache-adapter-fixed' and verify package.json includes the correct name.
TypeError: cache.store.length is not a function
The 'store' object does not have a 'length' method immediately; it may be asynchronous (localForage).
fix
Use 'await cache.store.length()' or '.then()' as the store API is promise-based.
Error: adapter is not a function
Passing the adapter incorrectly; setupCache returns an object with an adapter property.
fix
Use 'cache.adapter' when creating axios instance: axios.create({ adapter: cache.adapter }).
Upgrade
Version history
1.0.8latest on npm
Audit
Dependencies
axiosrequiredRuntime peer dependency; the adapter attaches to axios instances
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
axios-cache-adapter-fixed — npm install axios-cache-adapter-fixed · libregistry