[Service Worker] Offline mode reload doesn't work - Error 404
See original GitHub issueI’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
When I refresh my app on a specific url route, (for example, “/dashboard”) I directly get a 404 even if I’m online or offline.
Expected behavior
I should get to the specific page.
Minimal reproduction of the problem with instructions
ng build --prod && http-server dist -p 4100
-> Go on Chrome on 127.0.0.1:4100, everything works fine until I refresh on a specific url
Environment
Angular version: 5.0.0
"@angular/service-worker": "^5.2.2"
Browser:
- [X] Chrome (desktop) version 63.0.3239.132
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: 6.11.0
- Platform: Win10 x64
Others:
http-server: 0.11.1
Notes
I googled the problem and he appears to be something in link with the service worker routing. Everytime they speak about a ngsw-manifest.json
file that I don’t have on dist
after the build.
Is there a way to done it properly in ngsw-config.json
?
Here is mine :
{
"index": "/index.html",
"dataGroups": [{
"name": "tasks-users-api",
"urls": [
"/collaborateurs",
"/suivis/",
"/webService/ordresMissions/*"
],
"cacheConfig": {
"strategy": "freshness",
"maxSize": 100,
"maxAge": "1h",
"timeout": "10s"
}
}],
"assetGroups": [{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/index.html"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}]
}
Thank’s in advance
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Service Workers - When Fetch Goes Wrong - YouTube
This video explains how you can use your Service Worker to handle an offline -first app as well has gracefully handling 404 errors....
Read more >Service worker returning Offline page instead of 404 page ...
I'm using this service worker for caching and offline mode. ... 404) { return cache.match("/service/offline/"); but i don't know how to fix ...
Read more >Progressive Web Apps: Going Offline - Google Developers
Explanation. During the service worker's install event, a named cache is opened using the Cache Storage API. The files and routes specified in ......
Read more >Service Workers Break the Browser's Refresh Button by Default
The core feature of offline-enabled Service Workers is… ... return a 404 error for sw.js each time we refresh, but the Service Worker...
Read more >Resource Handling & Service Workers - Gatsby
For paths which aren't in this array, we load the HTML from the server as usual, which allows for native offline error pages...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
ng serve
doesn’t have Service Worker enabled.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.