question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Service Worker] Offline mode reload doesn't work - Error 404

See original GitHub issue

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

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:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alxhubcommented, Feb 6, 2018

ng serve doesn’t have Service Worker enabled.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 13, 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found