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.
var createDeltaCache = require('delta-cache');
var deltaCache = createDeltaCache();
var server = http.createServer((req, res) => {
deltaCache(req, res, 'sample dynamic response ' + new Date().toString());
});
Returns a DeltaCache
instance.
This class internally contains file versions that are saved to disk.
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.