alltherooms / cached-request

Node.js module to perform HTTP requests with caching support
MIT License
61 stars 23 forks source link

Force to cache again the request #27

Closed Clebal closed 7 years ago

Clebal commented 7 years ago

Hello, I don't know if it's implemented (at least I don't see it in docs) but I would want to delete the cache before ttl time ends and make a new cached request again.

danypype commented 7 years ago

If you specify a new ttl at the time of the request, this will be used. Example:

var cr = require('cached-request')(request);
cr({url: 'http://www.google.com'}); //the request is made and its response is cached
cr({url: 'http://www.google.com', ttl: 10000}); //the response is retrieved from the cache
cr({url: 'http://www.google.com', ttl: 0}); //the request is made and its response is cached
Clebal commented 7 years ago

Oh, it makes sense! 😄 Thank you @danypype