kapouer/window-page

consider using pageshow/pagehide, and/or freeze/resume events

Opened this issue · 0 comments

https://web.dev/bfcache/#update-stale-or-sensitive-data-after-bfcache-restore

window-page is made to deal with:
Page.build -> 401 -> shows login page -> login -> rebuild page -> 200

However this doesn't work with bfcache - the login page is shown when going back, even if user is still logged in.

window.addEventListener('pageshow', (event) => {
  if (event.persisted && Page.state.wasBuiltTwice) {
    // Force a reload if the user has logged out.
    Page.state.reload();
  }
});