🗄️📦💿 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
```ts 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. ```sh # 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: - [axios-cache-adapter](https://github.com/RasCarlito/axios-cache-adapter) - [axios-cache-plugin](https://github.com/jin5354/axios-cache-plugin) - [@tusbar/cache-control](https://github.com/tusbar/cache-control)
### License Licensed under the **MIT**. See [`LICENSE`](LICENSE) for more informations.
### Contact See my contact information on my [github profile](https://github.com/ArthurFiorette) or open a new issue.