Skip to content

Service Worker not caching anything #10361

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

Closed
GaryB432 opened this issue Apr 16, 2018 · 5 comments
Closed

Service Worker not caching anything #10361

GaryB432 opened this issue Apr 16, 2018 · 5 comments
Assignees
Labels
needs: more info Reporter must clarify the issue P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Milestone

Comments

@GaryB432
Copy link

Versions

Angular CLI: 6.0.0-rc.4
Node: 9.3.0
OS: win32 x64
Angular: 6.0.0-rc.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.6
@angular-devkit/build-angular     0.5.6
@angular-devkit/build-optimizer   0.5.6
@angular-devkit/core              0.5.6
@angular-devkit/schematics        0.5.6
@angular/cli                      6.0.0-rc.4
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.0-rc.4
@schematics/angular               0.5.6
@schematics/update                0.5.6
rxjs                              6.0.0-uncanny-rc.7
typescript                        2.7.2
webpack                           4.5.0

Repro steps

git clone https://github.com/GaryB432/angular-pwa
cd angular-pwa
git fetch origin
git checkout -b test origin/v6
npm install
ng build --prod
docker build -t issue-repro .
docker run -d -p 8080:80 issue-repro

visit http://localhost:8080 and reload/clear until the sw registers

Observed behavior

Chrome Dev Tools shows

  • IndexedDB is empty
  • many caches but all empty save one

Desired behavior

I expected IndexedDB and Cache Storage to contain some entries like in 1.7

Mention any other details that might be useful (optional)

I notice ngsw.json is quite different but I believe it used to contain the hashed names.

  • why so many caches? What is their purpose?
  • How to make use of safety-worker? I want to build a 'kill-switch' and I suppose that is safety-worker's purpose. Is a kill-switch already built-into ngsw.worker.js?
@filipesilva filipesilva added this to the v6.0.0 milestone Apr 17, 2018
@filipesilva
Copy link
Contributor

@GaryB432 can you try @angular/cli@6.0.0-rc.5 together with @angular-devkit/build-angular@0.5.7 please?

I think I fixed this with angular/devkit#709 but there might be more leftover cases.

@filipesilva filipesilva self-assigned this Apr 17, 2018
@filipesilva filipesilva added the needs: more info Reporter must clarify the issue label Apr 17, 2018
@GaryB432
Copy link
Author

Thanks for looking. I will get to this soon since I can only work on this cool stuff in my spare time. Looking at your related merge I see '@angular/pwa'. Should I be using that instead of rolling SW by hand? See https://stackoverflow.com/questions/49880891/how-to-use-the-angular-pwa-schematics-library

@GaryB432
Copy link
Author

GaryB432 commented Apr 20, 2018

The repo above is now using @angular/cli@6.0.0-rc.5 and @angular-devkit/build-angular@0.5.7. I also used ng add @angular/pwa instead of adding sw by hand now that I know about add. It does look like you nailed ngsw.json.

However

  • IndexedDB and caches still unexpectedly empty
  • manifest.json is under assets instead of in the root. I can open an issue with @angular/pwa if you need that
Angular CLI: 6.0.0-rc.5
Node: 9.3.0
OS: win32 x64
Angular: 6.0.0-rc.5
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.7
@angular-devkit/build-angular     0.5.7
@angular-devkit/build-optimizer   0.5.7
@angular-devkit/core              0.5.7
@angular-devkit/schematics        0.5.7
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.0-rc.5
@schematics/angular               0.5.7
@schematics/update                0.5.7
rxjs                              6.0.0-uncanny-rc.7
typescript                        2.7.2
webpack                           4.5.0

@hansl hansl added the P5 The team acknowledges the request but does not plan to address it, it remains open for discussion label Apr 23, 2018
@gkalpak
Copy link
Member

gkalpak commented Apr 30, 2018

The manifest.json issues have been fixed in #722. I tried with @angular/cli@6.0.0-rc.7 and everything (mentioned in this issue) seems to work fine. IndexedDB is empty (as expected) and the caches are populated.

Closing. Please, open a new issue if there are still problems/things to be improved.

@gkalpak gkalpak closed this as completed Apr 30, 2018
@angular-automatic-lock-bot
Copy link

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 Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

No branches or pull requests

4 participants