Registry / storage / cachios

cachios

JSON →
library4.0.0jsnpmunverified

Cachios is a lightweight wrapper around axios that adds in-memory caching using node-cache. Version 4.0.0 is the current stable release. It provides a simple drop-in replacement for axios with minimal configuration, caching responses by default and offering TTL control, force refresh, and custom cache backends. Unlike other caching libraries, it uses a trimmed cache (status and data) and integrates seamlessly with existing axios instances. Release cadence is low (major version bumps infrequent).

npm install cachios
INSTALL
IMPORT
SIG · CACHIOS
C
cachios
storagejavascriptv4.0.0
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.

cachios
import cachios from 'cachios'
const cachios = require('cachios')
ESM default import; works in TypeScript with esModuleInterop.
create
import { create } from 'cachios'
const { create } = require('cachios')
Named export for creating a custom instance.
CachiosInstance
import type { CachiosInstance } from 'cachios'
import { CachiosInstance } from 'cachios'
TypeScript type export for instance variables.

Demonstrates basic caching with TTL, automatic cache hit, and force refresh with TypeScript.

import cachios from 'cachios'; async function getPost(id: number) { const response = await cachios.get(`https://jsonplaceholder.typicode.com/posts/${id}`, { ttl: 60, // cache for 60 seconds }); return response.data; } // First call - fetches from API const data1 = await getPost(1); console.log('First call:', data1); // Second call within 60s - returns cached data const data2 = await getPost(1); console.log('Second call (cached):', data2); // Force refresh const data3 = await cachios.get(`https://jsonplaceholder.typicode.com/posts/1`, { force: true, }); console.log('Force refresh:', data3.data);
Debug
Known issues
gotchaOnly response.data and response.status are cached by default. Other fields like headers are not preserved unless custom response copier is used.
fix
Set a custom responseCopier option on cachios.create to include additional fields.
affects: >=4.0.0
breakingThe cachios instance no longer extends axios directly; it exports an axios-like object. In v3, cachios was a direct axios wrapper with all axios methods; v4 changed the instance structure.
fix
Use cachios.create(axiosInstance) to get a custom instance, or use the default export.
affects: >=4.0.0
deprecatedCachios v3 and earlier required CommonJS require; v4 is ESM-first. Using require() may cause issues with TypeScript or bundlers.
fix
Switch to import syntax: import cachios from 'cachios'.
affects: <4.0.0
Errors
Common errors & fixes
Cannot find module 'cachios'
Package not installed or used in a CommonJS file without proper bundler configuration.
fix
Install with 'npm install cachios' and ensure you are using ESM (e.g., type: 'module' in package.json) or use dynamic import.
TypeError: cachios.get is not a function
Using the default import incorrectly or creating an instance without calling create.
fix
Use import cachios from 'cachios' (default export) or const instance = cachios.create(axios); then instance.get(...).
Error: Unknown cache key format
Using a custom cache that expects different key format, or the internal cache failed to parse.
fix
Ensure you are not overriding the cache key manually; if using custom cache store, implement get/set correctly.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
axiosrequiredCachios wraps axios and is a direct dependency (not peer, but required at runtime).
node-cacheoptionalUsed internally as the default cache store.
Agent activity
24 hits · last 30 days
node
24
Resources
cachios — npm install cachios · libregistry