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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.