An HTTP client with caching, built on top of request.
An HTTP client with caching, built on top of request.
It works as a drop-in replacement for request
. All that is needed is to pass a cache
option:
request
ETag
by using If-None-Match
var LRU = require('lru-cache');
var public_lru = new LRU();
var private_lru = new LRU();
var cache = new MemoryCache(public_lru, private_lru);
request('http://some.url', {cache: cache}, function(err, res, body) {
});
The cache
object must be an object with the following methods:
add(key, private, val, function(err){})
get(key, function(err, val){})
If-None-Match
value from cached response's ETag
.