Open elhoyos opened 5 years ago
Using
// test.js const request = require('request') const cr = require('./lib/index')(request) cr.setCacheDirectory('/tmp/cache'); const log = (i) => (err, response, body) => { if (err) throw err; const cached = !!response.headers["x-from-cache"]; console.log(`${i}: ${response.statusCode}, ${cached}`); }; cr({url: 'https://www.google.com', ttl: 10000}, log(1)) cr({url: 'https://www.google.com', ttl: 10000}, log(2))
If I execute it after a non-cached response, these executions sometimes will result in nothing printed in the screen, and only after the cache expires I'm able to see results back again.
$ node test.js 1: 200, false 2: 200, false $ node test.js $ node test.js $ node test.js $ node test.js $ node test.js $ node test.js $ node test.js $ node test.js $ node test.js $ node test.js $ node test.js 1: 200, false 2: 200, false $ node test.js 1: 200, true 2: 200, true
Using
If I execute it after a non-cached response, these executions sometimes will result in nothing printed in the screen, and only after the cache expires I'm able to see results back again.