Strong-caching-http-client is an HTTP client with a transparent filesystem-based cache.
$ npm install strong-caching-http-client
The API is similar to the API of request.
var client = require('strong-caching-http-client');
client.request(
'http://nodejs.org/',
{
cache: '/tmp/http-client-cache'
},
function(err, resp) {
// resp is http.IncomingMessage
}
);
cache
Path to the directory where the client should keep cached data.method
GET/POST/etc.headers
Request headers (optional).body
Request body (optional). EitherString
,Buffer
orStream
.maxAge
Accept a cached response whose age is no greater that the specified time in seconds. Default: 60.maxStale
Accept a cached response that has exceeded its expiration time (as set by maxAge option) by no more than the specified time in seconds.