Project / Support Center
Welcome, %1$s. Please login or register. February 28, 2024, 10:28: AM
Web Global Net Web Application & Web Development Project Center  |  Technical Issues  |  Javascripting  |  : Forcing a browser page to reload when the back button is clicked to flush cache 0 and 1 Guest are viewing this topic. « previous next »
: [1]
: Forcing a browser page to reload when the back button is clicked to flush cache  ( 5311 )
admin
Administrator
******


: 239


« : August 25, 2021, 06:06: PM »

put this in the the head section


<script>
         /**
          * 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();
               }
            };
         })();
      </script>


Apple's own fix suggestion is to add an empty iframe on your page:

<iframe style="height:0px;width:0px;visibility:hidden" src="about:blank">
    this frame prevents back forward cache
</iframe>
 

The Unknown Webmaster
: [1]  
Web Global Net Web Application & Web Development Project Center  |  Technical Issues  |  Javascripting  |  : Forcing a browser page to reload when the back button is clicked to flush cache « previous next »
:  


Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!
Sorry, the copyright must be in the template.
Please notify this forum's administrator that this site is missing the copyright message for SMF so they can rectify the situation. Display of copyright is a legal requirement. For more information on this please visit the Simple Machines website.