diff --git a/packages/react-scripts/template/src/registerServiceWorker.js b/packages/react-scripts/template/src/registerServiceWorker.js index a3e6c0cfc10de36d6bcb38c52e00c012e985d68e..5ff7cdb7dd56bc95c9b1b2d5bcbf8c0c6e2bfecc 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.