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

fix: index.html in root is correctly cached #1266

Merged
merged 8 commits into from
May 12, 2022
Merged

Conversation

TheSlimvReal
Copy link
Collaborator

@TheSlimvReal TheSlimvReal commented May 11, 2022

Currently our offline functionality still has some limits. To reproduce:

  1. Clear browser cache (at least for demo.aam-digital.com)
  2. Visit https://demo.aam-digital.com/en-US/
  3. Turn off internet
  4. Reload page -> should work
  5. Visit https://demo.aam-digital.com/
  6. Does not work (not even loading... is shown)

This is because the root index.html (e.g. https://demo.aam-digital.com/index.html) is not actively cached by the service worker.
This PR changes this and adds correct handling of requests to root without locale.
Try the same with https://test-deployment-pr-1266.herokuapp.com/en-US/ and https://test-deployment-pr-1266.herokuapp.com/ and it should work.

Visible/Frontend Changes

--

Architectural/Backend Changes

  • Currently the index.html on root (e.g. demo.aam-digital.com) is not defined in the ngsw.json and only sometimes cached. This is no changed to prefetch which means it will actively be loaded and cached by the service worker

@github-actions
Copy link

@TheSlimvReal TheSlimvReal marked this pull request as draft May 11, 2022 15:17
@TheSlimvReal TheSlimvReal marked this pull request as ready for review May 12, 2022 08:38
Comment on lines +17 to +20
# Service Worker requests should not be changed
location ~* ^/ngsw {
try_files $uri =404;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that a manual request by user to ngsw/state or some internal ones by services?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its the ones for the ngsw-worker.js (so the actual service worker which we request in the app.module.ts) and the request for the ngsw.json which tracks the cached files and indicates updates which the service worker itself requests.

Copy link
Member

@sleidig sleidig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to work as described 👍

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@TheSlimvReal TheSlimvReal merged commit e2548ed into master May 12, 2022
@TheSlimvReal TheSlimvReal deleted the index_html_fix branch May 12, 2022 10:12
@aam-digital-ci
Copy link
Collaborator

🎉 This PR is included in version 3.6.0-master.14 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@aam-digital-ci
Copy link
Collaborator

🎉 This PR is included in version 3.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants