The ResponseManager

The ResponseManager contains common logic that correlates to some of the caching strategies covered in Chapter 7, Service Worker Caching Patterns. The ResponseManager class contains a condensed set of cache strategies and the corresponding methods for five caching strategies:

  • Cache only
  • Network only
  • Cache falling back to network
  • Cache falling back to network and caching response
  • Cache falling back to network, render result, and cache

This is the ResponseManager class definition with method signatures:

 class ResponseManager { fetchText(url) {...} fetchJSON(url) {...} fetchAndRenderResponseCache(options) {...} cacheFallingBackToNetwork(request, cacheName) {...} cacheFallingBackToNetworkCache(request, cacheName) {...} ...

Get Progressive Web Application Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.