Repository navigation
Closed
Labels
area: service-workerIssues related to the @angular/service-worker packageIssues related to the @angular/service-worker package
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Currently, an index path, /, is omitted by ngsw-config command. It was supported as routing in old ngsw version.
$ ngsw-config ./src ./src/ngsw.base.json
ngsw.base.json
{
"index": "src/index.html",
"assetGroups": [
{
"name": "site",
"mode": "prefetch",
"resources": {
"files": [
"/",
"/favicon.ico",
"/index.html"
],
"urls": [
"https://fonts.googleapis.com/**"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
}
]
}
Generated ngsw.json
{
"configVersion": 1,
"index": "/src/index.html",
"assetGroups": [
{
"name": "site",
"installMode": "prefetch",
"updateMode": "prefetch",
"urls": [
"/favicon.ico",
"/index.html"
],
"patterns": [
"https:\\/\\/fonts\\.googleapis\\.com\\/.*"
]
}
],
"dataGroups": [],
"hashTable": {
"/favicon.ico": "84161b857f5c547e3699ddfbffc6d8d737542e01",
"/index.html": "e5defb09b5dadd8903d71b868022bf69fc954f39"
}
}
Expected behavior
/ should be emitted as urls to cache index.html for offline support.
{
"configVersion": 1,
"index": "/src/index.html",
"assetGroups": [
{
"name": "site",
"installMode": "prefetch",
"updateMode": "prefetch",
"urls": [
"/", // <= should be in here
"/favicon.ico",
"/index.html"
],
"patterns": [
"https:\\/\\/fonts\\.googleapis\\.com\\/.*"
]
}
],
"dataGroups": [],
"hashTable": {
"/favicon.ico": "84161b857f5c547e3699ddfbffc6d8d737542e01",
"/index.html": "e5defb09b5dadd8903d71b868022bf69fc954f39"
}
}
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
I tried to migrate my app to new ngsw with #19795 as a referrence. But index.html is never cached.
Environment
Angular CLI: 1.5.0-rc.3
Node: 6.11.2
OS: darwin x64
Angular: 5.0.0-rc.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker
Metadata
Metadata
Assignees
Labels
area: service-workerIssues related to the @angular/service-worker packageIssues related to the @angular/service-worker package
Activity
webmaxru commentedon Oct 26, 2017
You don't need to add
/at all. The routing is done automatically now (there is no need to specify anything for this anymore). I believe you have caching failed because of non-default base-href. Do you pass it as a 3rd parameter to ngsw CLI? In your case it should look like this:ngsw-config dist src/ngsw.base.json /srcOfftop: @lacolaco, I'm in Tokyo Nov 13-16. My pleasure to meet you and maybe present something at ngJapan meetup!
lacolaco commentedon Oct 26, 2017
Hmm... I changed
indexproperty from/src/index.htmlto/index.html, but it seems not working well.generated ngsw.json
this project is made by Angular CLI and I added ngsw files.
P.S. @webmaxru I want to see you, too! please send email to suguru.inatomi[at]gmail.com about your trip. Let's adjust our schedule :)
webmaxru commentedon Oct 26, 2017
Try to upgrade to RC.6. Most likely it's the same bug as was in #19490
lacolaco commentedon Oct 26, 2017
I already upgraded to RC.6. (see environments in 1st comment)
lacolaco commentedon Oct 27, 2017
still happening in RC.7
alxhub commentedon Oct 27, 2017
Hi @lacolaco,
Once your site loads, please open a tab and access the debugging URL
/ngsw/state, and paste the contents here.Thanks!
lacolaco commentedon Oct 27, 2017
@alxhub Thank you. the below is that.
alxhub commentedon Oct 28, 2017
@lacolaco please have that URL open, refresh your app, wait a few seconds and refresh the debug URL. That log indicates a service worker that has never seen a
fetch.lacolaco commentedon Oct 28, 2017
@alxhub that's right. there is no log.
The weird thing is
favicon.icois cached correctly. Why notindex.html?lacolaco commentedon Oct 28, 2017
Ahhh, sorry, I had been enabled service worker's
update on reloadoption. I just got actual logslacolaco commentedon Oct 29, 2017
Repro: https://github.com/lacolaco/angular-service-worker-example/tree/3f68c1ba33eb6482db0e76f660f1de80d53e6ade
lacolaco commentedon Nov 7, 2017
At 5.0.0 stable, I finally get my offline cache!! I appreciate the team.
angular-automatic-lock-bot commentedon Sep 12, 2019
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.