How to change PWA workbox cache strategy in Create-React-App 2

Viewed 226

Create-react-app v2 uses the workbox cacheFirst strategy. I want to use staleWhileRevalidate. How can I create a custom service worker and add it too a exising app?

1 Answers

Please update to create-react-app v4 if you'd like more control over your service worker.

You can start a new project that will use a service worker that you can make changes to using:

npx create-react-app my-app --template cra-template-pwa

There are details in the current documentation.

Related