(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
pull/115/head
George Gevoian 3 years ago
parent 3055a11fb2
commit e997d091b3

@ -20,6 +20,14 @@ const ko = require('knockout');
setupKoDisposal(ko);
$(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);
// Set from the login tests to stub and un-stub functions during execution.
window.loginTestSandbox = null;

Loading…
Cancel
Save