Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
axios-cache-interceptor
Advanced tools
The axios-cache-interceptor package is a middleware for Axios that provides caching capabilities. It allows you to cache HTTP requests and responses, reducing the number of network requests and improving performance.
Basic Caching
This feature allows you to set up basic caching for your Axios requests. The example demonstrates how to create a cache with a maximum age of 15 minutes and use it with an Axios instance.
const axios = require('axios');
const { setupCache } = require('axios-cache-interceptor');
const cache = setupCache({
maxAge: 15 * 60 * 1000 // 15 minutes
});
const api = axios.create({
adapter: cache.adapter
});
api.get('https://api.example.com/data')
.then(response => console.log(response.data))
.catch(error => console.error(error));
Custom Cache Key
This feature allows you to define a custom cache key. The example shows how to create a cache key based on the request URL, method, and parameters.
const axios = require('axios');
const { setupCache } = require('axios-cache-interceptor');
const cache = setupCache({
key: req => req.url + req.method + JSON.stringify(req.params)
});
const api = axios.create({
adapter: cache.adapter
});
api.get('https://api.example.com/data', { params: { id: 1 } })
.then(response => console.log(response.data))
.catch(error => console.error(error));
Cache Invalidation
This feature allows you to manually invalidate the cache for specific requests. The example demonstrates how to invalidate the cache for a specific URL.
const axios = require('axios');
const { setupCache } = require('axios-cache-interceptor');
const cache = setupCache();
const api = axios.create({
adapter: cache.adapter
});
api.get('https://api.example.com/data')
.then(response => console.log(response.data))
.catch(error => console.error(error));
// Invalidate the cache for a specific request
cache.invalidate({ url: 'https://api.example.com/data' });
axios-cache-adapter is another caching library for Axios. It provides similar functionality to axios-cache-interceptor, allowing you to cache HTTP requests and responses. However, axios-cache-adapter offers more configuration options for cache storage, such as using localStorage or a custom store.
axios-extensions is a package that extends Axios with additional features, including caching. It provides a simple way to add caching to your Axios requests and supports various cache strategies. Compared to axios-cache-interceptor, axios-extensions offers more flexibility in defining cache strategies and expiration times.
⚡ Axios Cache Interceptor
Axios Cache Interceptor
is a small and efficient cache interceptor for axios.
import Axios from 'axios';
import { setupCache } from 'axios-cache-interceptor';
// same object, but with updated typings.
const axios = setupCache(Axios);
const req1 = axios.get('https://api.example.com/');
const req2 = axios.get('https://api.example.com/');
const [res1, res2] = await Promise.all([req1, req2]);
res1.cached; // false
res2.cached; // true
axios-cache-interceptor.js.org
🎉🎉
Licensed under the MIT. See LICENSE
for more informations.
See my contact information on my github profile or open a new issue.
v0.8.5 - 2022-01-23
#124
#123
f160428
2d779ec
7d314c2
df74939
706c4dd
bdbdd37
cb59384
95f4137
e9fc692
026465c
9b9ae3a
7ccac42
989ceec
b76087e
cc6523f
0ba6025
64c0f40
ea4ab4c
098cf47
7dc15be
d14750e
AxiosResponseHeaders
bd4bf26
31ef7e7
f09670d
FAQs
Cache interceptor for axios
The npm package axios-cache-interceptor receives a total of 72,717 weekly downloads. As such, axios-cache-interceptor popularity was classified as popular.
We found that axios-cache-interceptor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.