Mobile Safari uses a special caching mechanism Page Cache
(here) which basically keeps the current page alive but hibernated when we navigate to another page. T
When user presses back button, you will receive the same document as you had before (the old page which was suspended). So if you handle onpagehide
event and do some modification to the page just before navigating to the new page, your changes are kept there.
I tried adding a script block to the body
just before navigating:
if (isSafari) {
window.addEventListener('pagehide', function(e) {
var $body = $(document.body);
$body.children().remove();
$body.append("