You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
When using the default service worker configuration, if you change multiple pages in your app e.g. view1.html and view2.html and then reload the app following a build, the first page you hit (e.g. view1) will show the previously cached page, whereas the second page you hit (e.g. view2) will show the newer version.
This is because the sw-precache skipWaiting option defaults to true. However, for an app shell based app like the Polymer app toolbox apps this can lead to an inconsistent experience because you end up seeing different, inconsistent versions of your pages until the next time you load the app.
By setting skipWaiting to false, the first time you load the new version you continue to see the old version but at least it is consistent across pages. This does have the downside that you don't see any pages from your new version until the next time you load your app (assuming all tabs with the old service worker version have been removed) but this feels like it would be cleaner and less confusing?
Or maybe there is a better approach to working around this stale page problem?
Expected outcome
Displayed versions of pages in the app should be consistent.
Actual outcome
First page displayed after a rebuild/reload is always the previous version prior to the rebuild due to the service worker caching whilst subsequent pages you load will show a newer version due to the service worker immediate activation. You continue to see the previous version of the initial page loaded even when switching pages in the app, because once it's import has been loaded it doesn't get reloaded until you do a full reload of the app.
Steps to reproduce
Install and build the starter kit and load view1, view2 and view3 in a browser using a production build so that the service work is installed. (run polymer build --root build/es5-bundled
Modify the source for my-view1.html
Modify the source for my-view2.html
run polymer build
run polymer serve --root build/es5bundled
Reload the app in a web browser at view1 (the original version of view1 is displayed)
Click on the link for view2 (the newer version of view2 is displayed)
Click back on the link for view1 (you still see the older version)
Reload the browser page - now you see the newer versions for view1 and view2
=> The app is in an inconsistent state?
Browsers Affected
Only tested in Chrome but would affect other browsers that support service worker
The text was updated successfully, but these errors were encountered:
I'm not 100% sure about this, but even you still use the old SW, the cache would already be updated with the new my-view*.html. So when you load view2 (which dynamically loads my-view2.html), you'll get the new one.
But yes, you do potentially end up with files from different versions.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
When using the default service worker configuration, if you change multiple pages in your app e.g. view1.html and view2.html and then reload the app following a build, the first page you hit (e.g. view1) will show the previously cached page, whereas the second page you hit (e.g. view2) will show the newer version.
This is because the sw-precache skipWaiting option defaults to true. However, for an app shell based app like the Polymer app toolbox apps this can lead to an inconsistent experience because you end up seeing different, inconsistent versions of your pages until the next time you load the app.
By setting skipWaiting to false, the first time you load the new version you continue to see the old version but at least it is consistent across pages. This does have the downside that you don't see any pages from your new version until the next time you load your app (assuming all tabs with the old service worker version have been removed) but this feels like it would be cleaner and less confusing?
It took me a while to understand why it was behaving this way, so maybe this default behaviour could be called out in the docs (https://www.polymer-project.org/2.0/toolbox/service-worker) as something to be aware of?
Or maybe there is a better approach to working around this stale page problem?
Expected outcome
Displayed versions of pages in the app should be consistent.
Actual outcome
First page displayed after a rebuild/reload is always the previous version prior to the rebuild due to the service worker caching whilst subsequent pages you load will show a newer version due to the service worker immediate activation. You continue to see the previous version of the initial page loaded even when switching pages in the app, because once it's import has been loaded it doesn't get reloaded until you do a full reload of the app.
Steps to reproduce
=> The app is in an inconsistent state?
Browsers Affected
Only tested in Chrome but would affect other browsers that support service worker
The text was updated successfully, but these errors were encountered: