Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop older service workers?

The image below shows that there are two workers installed - one active and the other not active (just installed).

two service workers running

  1. Register a service worker
  2. Make changes to service-worker.js and reload the page.
  3. The logic is that Service Workers check binary diff and updates the versions of the workers.

So a new service worker is spawned with a new version ID. But why does the old one keeps running ? and How do I close it ?

The sw.js is here https://gist.github.com/boopathi/57b7e8b6d657d55bdc7d

like image 381
Boopathi Rajaa Avatar asked Jan 21 '15 14:01

Boopathi Rajaa


People also ask

Can a company get rid of an older employee?

One of the most common excuses used to get rid of older employees is “job elimination.” However, that may just be an excuse for what is really age discrimination. If the company is not really eliminating the job, just changing the title and putting someone younger is your former position, you may have an age discrimination claim.

Is ‘job elimination’ an excuse to get rid of older workers?

One of the most common excuses used to get rid of older workers is “job elimination.” Photo: Getty ... [+] Older workers are still suffering in the aftermath of the Great Recession. More than half the people aged 50 and older who participated in a recent AARP survey said they had either experienced or witnessed age discrimination in the workplace.

How are employers treating older workers in the US?

The U.S. has improved substantially in its treatment of older workers since the Age Discrimination in Employment Act was passed in 1967. Take a look at how employers are developing or enhancing programs to recruit and retain older workers. ProPublica and Urban Institute Studylexibility, Fairness, Trust, Empowerment Make Work Human

Are older workers being pushed out of their jobs before retirement?

Data analysis by ProPublica and the Urban Institute shows that more than half of older U.S. workers are pushed out of longtime jobs before they choose to retire. AgeOrganization and Employee DevelopmentOrganizational Exit


1 Answers

By default, until all tabs that have a page controlled by that old service worker are closed/unloaded, the old service worker will stay running. The new service worker will, well, "wait" in the "waiting" state.

There are options that change this default behavior. They're skipWaiting() and clients.claim().

When skipWaiting() is called from an installing service worker, it will, well, skip the "waiting" state and immediately activate. However, it will not necessarily take control of pages despite being activated—that's what clients.claim() will accomplish.

like image 95
Jeff Posnick Avatar answered Oct 01 '22 01:10

Jeff Posnick