delta-cache-browser

Service worker that provides worry-free support for HTTP delta caching


Keywords
encoding, diff, googlediffjson, change, caching
License
MIT
Install
npm install delta-cache-browser@0.1.2

Documentation

delta-cache-browser

Partially cache dynamic content and send only the changes over the wire.

When used with dynamic content, delta encoding can provide 62%-65% savings for HTML files.

There's no need to change any of your requests - simply include the following code and the service worker will automatically intercept requests and use delta caching if available.

Usage

// register the service worker if service workers are supported
if ('serviceWorker' in navigator) {
  // register the service worker (will activate with document reload)
  navigator.serviceWorker.register('delta_cache_sw.js').then(function() {
    console.log('delta cache service worker registered');
  });
}

If service workers are not supported, it will fallback to normal browser control.

Designed to work with delta-cache-express, but it complies with any RFC 3229 compliant server. The encoding used for the deltas is googlediffjson, JSON stringified patches returned from the google-diff-match-patch algorithm.