Registry / storage / axios-etag-cache

axios-etag-cache

JSON →
library1.4.0jsnpmunverified

Axios interceptor that adds automatic ETag caching for HTTP requests. It intercepts requests and adds If-None-Match headers, then caches responses with their ETags to return cached data on 304 responses, reducing bandwidth and server load. Current stable version is 1.4.0, with infrequent releases; communicates only via GitHub. Key differentiator: lightweight, zero-config ETag caching specifically for Axios, with optional custom cache storage (e.g., RxDB) and POST request support. Requires axios >= 0.24.0 as a peer dependency.

npm install axios-etag-cache
INSTALL
IMPORT
SIG · AXIOS-ETAG-CACHE
A
axios-etag-cache
storagejavascriptv1.4.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.

axiosETAGCache
import { axiosETAGCache } from 'axios-etag-cache'
const axiosETAGCache = require('axiosETAGCache')
Named export in both ESM and CJS. CommonJS users should destructure require.
BaseCache
import { BaseCache } from 'axios-etag-cache'
import BaseCache from 'axios-etag-cache'
BaseCache is a named export, not default.
CacheValue
import type { CacheValue } from 'axios-etag-cache'
import { CacheValue } from 'axios-etag-cache'
CacheValue is a type (interface). Use import type for TypeScript.

Basic setup of axios-etag-cache with Axios to enable ETag caching on GET requests.

const axios = require('axios'); const { axiosETAGCache } = require('axios-etag-cache'); const client = axiosETAGCache(axios); client.get('https://jsonplaceholder.typicode.com/posts/1') .then(response => { console.log('Data:', response.data); console.log('Cached:', response.cached); }) .catch(console.error);
Debug
Known issues
gotchaInterceptor may not work if Axios instance is already configured with other interceptors.
fix
Apply axiosETAGCache before adding other interceptors, or ensure order is correct.
affects: all
gotchaResponse.data may be null for cached 304 responses if server does not send body.
fix
Do not assume response.data is always present; check response.cached property.
affects: all
deprecatedNo known deprecations in this version.
affects: <=1.4.0
Errors
Common errors & fixes
TypeError: axiosETAGCache is not a function
Importing incorrectly: using default import instead of named import.
fix
Use import { axiosETAGCache } from 'axios-etag-cache'
Cannot find module 'axios-etag-cache'
Package not installed or wrong import path.
fix
Run npm install axios-etag-cache and ensure correct import/require.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
axiosrequiredPeer dependency: required to intercept requests and cache responses with ETag headers.
Agent activity
44 hits · last 30 days
node
38
OpenAI (training)
1
Resources
axios-etag-cache — npm install axios-etag-cache · libregistry