You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

axios-cache-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-cache-interceptor

Cache interceptor for axios

0.2.0
Source
npmnpm
Version published
Maintainers
1
Created
Source

  

🗄️📦💿 Axios Cache Interceptor




Forks Issues Stars License Codecov Npm



This library is in beta and can have breaking changes until v1.
Not ready for production usage!


axios-cache-interceptor is a axios wrapper for caching and preventing unneeded requests


import axios from 'axios';
import { createCache, SessionCacheStorage } from 'axios-cache-interceptor';

// Any custom axios instance
const api = axios.create();

// Other axios instance with caching enabled
const cachedApi = createCache(api, {
  // Store values on window.sessionStorage
  storage: new SessionCacheStorage(),

  // Use the max-age header to determine the cache expiration time
  interpretHeader: true
});

// Make a simple request, with caching support, to the api
const { data } = await cachedApi.get('https://api.example.com/');


Installing

Axios is a peer dependency and must be installed separately.

# Npm
npm install --save axios axios-cache-interceptor

# Yarn
yarn add axios axios-cache-interceptor

Inspiration

This project is highly inspired by several projects, written entirely in typescript, supporting https headers and much more.

Take a look at some similar projects:


License

Licensed under the MIT. See LICENSE for more informations.


Contact

See my contact information on my github profile or open a new issue.


Keywords

axios

FAQs

Package last updated on 20 Sep 2021

Did you know?

Socket

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.

Install

Related posts