-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Allow specifying a max age for the index page served by the Service Worker #39266
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
area: service-workerIssues related to the @angular/service-worker packageIssues related to the @angular/service-worker packagefeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under considerationopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).An issue that is suitable for a community contributor (based on its complexity/scope).state: confirmed
Milestone
Metadata
Metadata
Assignees
Labels
area: service-workerIssues related to the @angular/service-worker packageIssues related to the @angular/service-worker packagefeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under considerationopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).An issue that is suitable for a community contributor (based on its complexity/scope).state: confirmed
Currently the Service Worker will serve the specified index file on navigation requests, checking for updates once the application has started.
While this does provide offline support & improves the TTI, one issue is that there's no expiration date for said index file: a returning user who had visited the site two months back will effectively run a 2-months old version of the app. This is posing an issue for us as, in addition to requiring our API to remain backwards compatible for a long period, said user will not see new features / bug fixes until the next visit, possibly a few weeks after, causing slow upgrade cycles (as confirmed through our analytics)
There is currently not a straightforward way to handle that staleness issue:
dataGroupfor the index file with amaxAgemeans the app shell hash isn't checked anymore, which means the app version integrity isn't guaranteed.An intermediate solution could be to have a customizable maximum age for the app shell (index): if that max age (say a week) has been reached, the service worker would go to the network to re-fetch the shell. This effectively means that if a newer version of the app is available, all the new assets would have to be fetched for the app to load, losing the benefits of the SW background fetching. It would also break offline support for those users as well. However, frequently returning users would not experience that, and this would enforce a maximum staleness for the app.
There might be better ways to address the problem though, but the current situation of unlimited app cache duration isn't ideal.