timarney / react-app-rewired

Override create-react-app webpack configs without ejecting
MIT License
9.77k stars 425 forks source link

is there a way to completely disable caching on production build? #586

Closed Jared-Dahlke closed 2 years ago

Jared-Dahlke commented 2 years ago

I'm noticing a file in my build folder called service-worker.js which is autogenerated. I need to disable caching because it is causing sync issues with my external api.

How do I completely disable caching on production build? I'm using "react-app-rewired": "2.1.6", i am running: react-app-rewired build

Here is the service-worker.js file that is getting populated in my build folder on prod build:

/**
 * Welcome to your Workbox-powered service worker!
 *
 * You'll need to register this file in your web app and you should
 * disable HTTP caching for this file too.
 * See https://goo.gl/nhQhGp
 *
 * The rest of the code is auto-generated. Please don't update this file
 * directly; instead, make changes to your Workbox build configuration
 * and re-run your build process.
 * See https://goo.gl/2aRDsh
 */

importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");

importScripts(
  "/precache-manifest.e2210178a185125695fbae86bfd27624.js"
);

self.addEventListener('message', (event) => {
  if (event.data && event.data.type === 'SKIP_WAITING') {
    self.skipWaiting();
  }
});

workbox.core.clientsClaim();

/**
 * The workboxSW.precacheAndRoute() method efficiently caches and responds to
 * requests for URLs in the manifest.
 * See https://goo.gl/S9QRab
 */
self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});

workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/index.html"), {

  blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/],
});
timarney commented 2 years ago

Closing --- this given it's not a bug and no activity.