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

Refreshing a route while offline fails (angular service worker) #22110

Closed
maa105 opened this issue Feb 9, 2018 · 4 comments
Closed

Refreshing a route while offline fails (angular service worker) #22110

maa105 opened this issue Feb 9, 2018 · 4 comments
Labels
area: service-worker Issues related to the @angular/service-worker package
Milestone

Comments

@maa105
Copy link

maa105 commented Feb 9, 2018

Moved it from angular/angular-cli#9558

Versions:

Windows Server 2008
Angular Version 5.2.4
Angular CLI: 1.6.4
Node: 8.9.1
OS: win32 x64
Angular:
...

Reproduce:
1- Create new angular with service worker and routing (ng new app --service-worker --routing)
2- add a route /home with a link to go to the /home
3- build and deploy
4- open site
5- go to /home page by clicking on the link
6- go offline
7- refresh browser

Observed behavior
when u refresh it fails (cause the URL is /home and /home was not cached but /index.html was)

Desired behavior
since the /home is just the same as /index.html but at a different route it should not fail, the problem won't show if you are offline cause this is handled by the server as in the following script app.get('*', function (req, res) { res.redirect('/index.html'); });. so the server knows about it and just return index.html. but the service worker doesn't (it just cached /index.html not /home). I guess my request/question is to be able in the service worker to create a default file for all routes or routes that do not have caching rules.

the workaround, for now, use hash routing instead of path routing (https://angular.io/guide/router#browser-url-styles)

@jackkoppa
Copy link

We've been discussing a similar issue at #21636, which I think is the same root cause - response of 504 Gateway Timeout when trying to access a non-index route, while offline. My SO question is currently open, on this issue, but thus far no one has been able to give any explanation for how this case should be handled. I've still been trying to step through the generated ngsw.js file, to see where the failure occurs for non-index routes offline (such that it does not fail for the index route); I don't yet have an answer on that.

@jackkoppa
Copy link

This issue can probably be closed as a duplicate of 21636. In the meantime, see this repo with a minimal reproduction to run locally.

@mhevery mhevery added the area: service-worker Issues related to the @angular/service-worker package label Feb 13, 2018
@ngbot ngbot bot added this to the needsTriage milestone Feb 26, 2018
@gkalpak
Copy link
Member

gkalpak commented Mar 2, 2018

Closing as duplicate of #21636.

@gkalpak gkalpak closed this as completed Mar 2, 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 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: service-worker Issues related to the @angular/service-worker package
Projects
None yet
Development

No branches or pull requests

4 participants