NfNitLoop / feoblog

A distributed, cryptographically-verifiable blog / social network
Other
71 stars 4 forks source link

Fix back behavior in iOS Safari #88

Closed NfNitLoop closed 2 years ago

NfNitLoop commented 2 years ago

See: https://gomakethings.com/fixing-safaris-back-button-browser-cache-issue-with-vanilla-js/

which recommends:

/**
 * If browser back button was used, flush cache
 * This ensures that user will always see an accurate, up-to-date view based on their state
 * https://stackoverflow.com/questions/8788802/prevent-safari-loading-from-cache-when-back-button-is-clicked
 */
(function () {
    window.onpageshow = function(event) {
        if (event.persisted) {
            window.location.reload();
        }
    };
})();

Need to investigate further and make sure that only affects Safari.

NfNitLoop commented 2 years ago

That seems to have done the trick. Nice.