0.0.1 • Published 4 years ago

@dbgso/axios-node-cache-adapter-tmp v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

axios-node-cache-adapter

  • Axios cache adapter for Node.js
  • Ignore to useless requests to server.
  • Inspired by scrapy.

Usage

$ yarn add axios-node-cache-adapter
// or
$ npm install axios-node-cache-adapter
import axiso from "axios";
import { setupCache } from "axios-node-cache-adapter";
async function main() {
    const io = axiso.create({
        adapter: setupCache({
            enable: true
        }),
    })
    console.time('first')
    const first = await io.get('https://www.example.com');
    console.timeEnd('first')

    console.time('second')
    const second = await io.get('https://www.example.com');    
    console.timeEnd('second')
    
    console.time('third')
    const third = await io.get('https://www.example.com');    
    console.timeEnd('third')
    

    console.log(first.data === second.data);
    
}
main();

result

first: 537.650ms
second: 3.383ms
second: 1.678ms
true
0.0.1

4 years ago