Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
React Cache Busting - Reloading the Page After Clearing Cache

I have been researching the topic for several days now and have yet to find a pure js solution that works. After clearing the browser cache (cache busting), is there a way in JS / React to reload the page with the new version?

At the moment, after clearing the cache the users have to close the browser and visit the site again before they can see the new version... as the cache is only cleared after it is already loaded. Manually refreshing the page does not work either - the browser must be closed.

I have seen several suggestions to use window.location.reload(true), but that does not seem to work anymore on modern browsers.

I would prefer to be able to do it purely on the client side, if possible.

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

When you register service worker in index.js file.

serviceWorkerRegistration.register();

The service worker starts working. But based on a problem, it can not activate itself. :)

enter image description here

To solve this problem, you can overwrite the service-worker.js file .

Instead of this code

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

});

You can follow this method

self.addEventListener('install', event => event.waitUntil(self.skipWaiting()));
self.addEventListener('activate', event => event.waitUntil(self.clients.claim()));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!