diff --git a/packages/react-scripts/template/src/registerServiceWorker.js b/packages/react-scripts/template/src/registerServiceWorker.js index a3e6c0cfc10..5ff7cdb7dd5 100644 --- a/packages/react-scripts/template/src/registerServiceWorker.js +++ b/packages/react-scripts/template/src/registerServiceWorker.js @@ -30,7 +30,9 @@ export default function register() { } window.addEventListener('load', () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + // Avoid service worker caching issues. + const noCache = new Date() * 1; + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js?nocache=${noCache}`; if (isLocalhost) { // This is running on localhost. Lets check if a service worker still exists or not.