Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(service-worker): clear service worker cache in safety worker #43324

Closed

Conversation

@naveedahmed1
Copy link
Contributor

@naveedahmed1 naveedahmed1 commented Sep 2, 2021

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes #43163

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • [ x] Bugfix
  • [ x] Improvements in safety worker

What is the current behavior?

Currently, safety worker only unregisters old service worker, while leaving the service worker cache. This creates problem when cache contains broken contents and sometimes causes new service worker to serve the contents from the old cache. Hence failing the purpose of safety worker.

Issue Number: 43163

What is the new behavior?

After unregistering old service worker, clear cache of angular service worker. This ensure that the new service worker doesn't serve stale or broken contents.

Does this PR introduce a breaking change?

  • Yes
  • [x ] No
Copy link
Member

@gkalpak gkalpak left a comment

Thx, @naveedahmed1 👍

I've left a couple of suggestions. Could you also mention the change in the Safety Worker section of Service worker in production guide? 🙏

packages/service-worker/safety-worker.js Outdated Show resolved Hide resolved
@naveedahmed1
Copy link
Contributor Author

@naveedahmed1 naveedahmed1 commented Sep 7, 2021

Thanks @gkalpak I have incorporated the changes you suggested. I hope everything is in order now :D

packages/service-worker/safety-worker.js Outdated Show resolved Hide resolved
@naveedahmed1 naveedahmed1 requested a review from gkalpak Sep 7, 2021
Copy link
Member

@gkalpak gkalpak left a comment

Thx for making the changes, @naveedahmed1 👍
I have left a couple of small suggestions regarding the docs. Can you also please ensure that there is only a single commit on the PR (since this is conceptually a single change) 🙏

aio/content/guide/service-worker-devops.md Outdated Show resolved Hide resolved
aio/content/guide/service-worker-devops.md Outdated Show resolved Hide resolved
@naveedahmed1 naveedahmed1 force-pushed the safety-worker-improvements branch from 5343e3a to b7b83a8 Sep 13, 2021
@pullapprove pullapprove bot requested a review from atscott Sep 13, 2021
@google-cla
Copy link

@google-cla google-cla bot commented Sep 13, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Sep 13, 2021
Copy link
Member

@gkalpak gkalpak left a comment

Thx, @naveedahmed1 👍

It looks good to me, except I still see 5 commits on the PR: https://github.com/angular/angular/pull/43324/commits
Can you please make sure there is only a single commit?

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes angular#43163
@gkalpak gkalpak force-pushed the safety-worker-improvements branch from b7b83a8 to 95320bf Sep 13, 2021
@google-cla google-cla bot added cla: yes and removed cla: no labels Sep 13, 2021
@gkalpak gkalpak removed request for IgorMinar and atscott Sep 13, 2021
AndrewKushnir added a commit that referenced this issue Sep 13, 2021
)

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes #43163

PR Close #43324
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
…ular#43324)

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes angular#43163

PR Close angular#43324
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
…ular#43324)

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes angular#43163

PR Close angular#43324
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Oct 14, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants