2021-09-01 13:30:26 -03:00

20 lines
490 B
TypeScript

// Readme example
import axios from 'axios';
import { createCache, SessionCacheStorage } from '../src/index';
// Any custom axios instance
const api = axios.create();
// Other axios instance with caching enabled
const cache = createCache(api, {
// Store values on window.sessionStorage
storage: new SessionCacheStorage(),
// Use the max-age header to determina the cache expiration time
interpretHeader: true
});
// Exactly the same as before
cache.get('http://example.com/');