Closed Bug 1294216 Opened 9 years ago Closed 9 years ago

Service Workers only clear old caches manually

Categories

(Core :: DOM: Service Workers, defect)

48 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: hakuno, Unassigned)

Details

(Keywords: 64bit)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0 Build ID: 20160726073904 Steps to reproduce: I update the files. I create a new cache version. Actual results: The activate event doesn't seem to be fired properly. Expected results: The activate function event should clear the old cache versions. See attachment.
Keywords: 64bit
OS: Unspecified → Windows 7
Hardware: Unspecified → x86_64
Do you have controlled tabs open? If so, then the new worker will be stuck in the waiting state until they are closed. If you don't want to wait for those to be closed you can use skipWaiting(): https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/skipWaiting Does the help?
Flags: needinfo?(hakuno)
Thank you so. Well, you're right. The web developer (F12) seems to be considered an opened page tab. If I try to debug on-the-fly by looking at console, I can't see the activate event in action then. But, it is okay for Chrome. What a difference! So is it a bug? Or need I mark it as resolved? Ps.: I'll test the skipWaiting as soon.
By the way, the skipWaiting and claim do the trick.
(In reply to hakuno from comment #2) > But, it is okay for Chrome. What a difference! Do you have "update on reload" checked for the service worker in chrome devtools? Its in the "application" devtools tab under "service workers".
Currently it's unchecked. Service Workers: > "Offline" option: is unchecked > "Update on reload" option: is unchecked > "Bypass for network" option: is unchecked
So you are saying this works in chrome without skipWaiting() or "update on reload"? 1) Load page with existing service worker 2) In web console verified its controlled by typing: console.log(navigator.serviceWorker.controller) 3) Update the service worker on your server 4) Reload the controlled page 5) Update process begins and starts install of new service worker You are saying at this point chrome sets the new service worker to active without closing the existing controlling page? That would be a bug in chrome.
> So you are saying this works in chrome without skipWaiting() or "update on reload"? No, I don't. Whenever it has no skipWaiting present, I just can force update by pressing Ctrl+F5 on Chrome. There's no issue at moment. The problem is based on that you've already said: I can't leave any tab related to the page. Because the Firefox even understands devtools/console as tab. So I'm obligated to close the console to remind the browser there's okay to proceed with. Anyway, the skipWaiting makes both run alike by now and on.
(In reply to hakuno from comment #7) > > So you are saying this works in chrome without skipWaiting() or "update on reload"? > > No, I don't. Whenever it has no skipWaiting present, I just can force update > by pressing Ctrl+F5 on Chrome. There's no issue at moment. Ctrl-f5 on chrome is a hard refresh which bypasses service worker. If you use ctrl-shift-r in firefox you will get the same effect. At this point I think its probably fair to close the bug. Please re-open if you think there is still a problem. Thanks!
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Flags: needinfo?(hakuno)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: