Search code examples
workbox

Different ways to implement Workbox?


I have seen many code examples of Workbox [3][4] and it seems like they all just how different ways of implementing same workbox functionality. So you can:

  • Create your own custom file + injectManifest from workbox-build or workbox-cli
  • Create your own custom file with precache list with workbox-precaching [1], custom routes with workbox-routing [2]
  • Create service worker file purely from workbox-cli / workbox-build

Am I right, or I misunderstood everything?


Solution

  • Using precaching is optional, and most of the methods that you describe assume that you will be using precaching. If you do choose to using precaching, then integrating with build tools to create that precache manifest is a requirement.

    Otherwise, you can just use pieces of Workbox from a hand-crafted service worker file to implement only, e.g., routing and runtime response strategies.