Skip to content
Modified is a simple request client to deal with http local cache.
JavaScript Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE-MIT
Makefile
README.md
index.js
package.json

README.md

NPM version Build Status Dependency Status

modified

Modified is a simple request client to deal with http local cache.

Modified implemented last-modified, if-modified-since, etag, if-none-match of HTTP specifications.

Synopsis

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 = modified(options); // Then use it almost the same as request

request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'));

Using modified with cache

If your server supports etag, or checks the if-modified-since header, modified will manage the local cache for you.

To enable caches, options.cache should be specified. modified only has one built-in cache handler modified.lruCache(cache_options).

var request = modified({
    cache: modified.lruCache(cache_options)
});

See modified-lru-cache for details.

Available caches

Implement your own caches

cache.read(req, callback)

  • req http.ClientRequest
  • callback function(headers)

cache.save(req, res, callback)

  • res http.ServerResponse
  • callback function(headers)

Programmatical APIs

var request = modified(options);

request(options, callback)

modified(options) returns a function which acts nearly the same as request;

Returns

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):

Event: 'complete'

Emitted when all the request process is complete, after the execution of user callback (the one of request(options, callback)).

MIT License

Copyright (c) 2013 Kael Zhang i@kael.me, contributors http://kael.me/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.