(core) Disable bfcache for all browsers

Summary:
Grist would get stuck in a broken state in certain browsers
that enabled the bfcache when the browser back/forward
buttons were clicked. Firefox automatically disabled the cache
since we listen on the 'beforeunload' event, but Chrome and Safari
did not. This change forces a page refresh on pageshow if we
detect that Grist was loaded from the bfcache.

Test Plan: Tested manually in various browsers.

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz, jarek

Differential Revision: https://phab.getgrist.com/D3151
This commit is contained in:
George Gevoian 2021-11-22 19:21:40 -08:00
parent 3055a11fb2
commit e997d091b3

View File

@ -20,6 +20,14 @@ const ko = require('knockout');
setupKoDisposal(ko); setupKoDisposal(ko);
$(function() { $(function() {
// Manually disable the bfcache. We dispose some components in App.ts on unload, and
// leaving the cache on causes problems when the browser back/forward buttons are pressed.
// Some browsers automatically disable it when the 'beforeunload' or 'unload' events
// have listeners, but not all do (Safari).
window.onpageshow = function(event) {
if (event.persisted) { window.location.reload(); }
};
window.gristApp = App.create(null); window.gristApp = App.create(null);
// Set from the login tests to stub and un-stub functions during execution. // Set from the login tests to stub and un-stub functions during execution.
window.loginTestSandbox = null; window.loginTestSandbox = null;