Modified is a simple request client to deal with http local caches.
Modified is a simple request client to deal with http local cache.
if-none-match of HTTP specifications.
Modified is built upon request and flavors it with cache support, so if you are familiar with request, you are almost ready to use modified.
var modified = require'modified';var request = modifiedoptions; // Then use it almost the same as requestrequest''pipefscreateWriteStream'doodle.png';
If your server supports etag, or checks the
modified will manage the local cache for you.
options.cacheMapper is not specified, caches will be saved into
'~/.node_modified/' directory by default.
But you can do it yourself for better control.
var request = modified// your code...callbacknullpathjoinpathToSaveNpmCacheurlparseoptionsuripathname'couchdb-document.json';;requestmethod: 'GET'url: ''// ...
The file path of the local cache to save response body according to a specific request. (Response headers will be saved into
cache_file + '.modified-headers.json')
If you don't want modified to cache for a certain request,
cache_file should be set to
var path = urlparseoptionsurlpathname;if path// '' -> '/abc'path = pathreplace/\/$/ '';callbacknull// Where the cache should be saved.pathjoin__dirname 'cache' path;elsecallbacknull null;
options.cacheMapper, you could specify the paths where the cache will be saved.
var request = modified(options);
function()Which is described above
modified(options) returns a function which acts nearly the same as
request(options, callback) returns an instance of
modified.Modified which is a sub-class of Readable Stream.
A instance of
Modified is an EventEmitter with the following extra event(s):
http.ServerResponseThe response object
StringThe response body
Emitted when all the request process is complete, after the execution of user callback (the one of
2.0.0 - Completely redesigned.
1.1.0 - Modified instances are streams now. You can use modified to fetch binary files.
1.0.0 - Initial release