delta-cache
v0.2.0
Published
Node server-side support for RFC 3229 delta encoding
Downloads
20
Maintainers
Readme
delta-cache-node
Node server-side support for delta caching
Complies with the RFC 3229 delta encoding spec with googlediffjson encoded deltas, so it works with delta-cache-browser.
Getting Started
var createDeltaCache = require('delta-cache');
var deltaCache = createDeltaCache();
var server = http.createServer((req, res) => {
deltaCache(req, res, 'sample dynamic response ' + new Date().toString());
});
API
createDeltaCache()
Returns a DeltaCache
instance.
Class: DeltaCache
This class internally contains file versions that are saved to disk.
deltaCache.respondWithDeltaEncoding(req, res, data[, fileId][, callback])
req
http.IncomingMessageres
http.ServerMessagedata
String | BufferfileId
String = require('url').parse(req.url).pathcallback
Function()
Sends a response with data
to the client, using delta encoding if possible. If fileId
is not given, it defaults to the path of the request URL. The parameter fileId
identifies the file in the server version history, so a second request to the same fileId
will give a delta encoded response (provided the client cached the first).
All versions of data are stored in disk in the filesystem as temporary files, and will be deleted when the Node process exits. To see the implementation of the version cache, see delta-history.