How to disable caching and switching on iOS Safari?

In ASP.NET MVC, we had problems disabling back and forth caching on iOS. We do not want our pages on our site to be accessible using the back and forward buttons for security reasons. We tried setting:

[OutputCache(NoStore = true, Duration = 1)]

And a bunch of other things, but nothing works. We cannot do anything in the onunload event, because iOS ignores this too. Any ideas?

+4
source share
1 answer

As we finally decided, this does this in the Layout view:

<script type="text/javascript">
     @Html.Raw("var freshPage = true;")
 </script>

javascript true, #, , . javascript, , :

window.addEventListener('popstate', function () {
  // If fresh page is false that means it is a cached page, remove html and reload page.
  if (!freshPage) {
    $('html').remove();
    window.location.reload();
  } else {
    freshPage = false;
  }
});

, , iOS , . iOS , "" "", . , , , false. , , , , freshPage , #, html .

+4

Source: https://habr.com/ru/post/1536980/


All Articles