How to prevent Safari cache loading from Safari?

I noticed a general error using the browser button in my web application where clicking the back button after logging out loads the cached page on which the user logs in (although this is actually not the case).

I found many useful questions with useful answers and used the proposed fixes, including each combination of the proposed Cache-Control options in the header:

('Cache-Control', 'no-cache, no-store, must-revalidate, max-age=0, max-stale=0')

And the header works in most browsers, even without a cache and without storage, but no header option allows this on Safari.

Of course, the most reliable way to find this for Safari is to use some kind of javascript as such, which forces you to reload:

<script>
            window.onpageshow = function(event) {
                if (event.persisted) {
                    window.location.reload();
                }
            };
</script>

javascript , javascript Safari → → "". , , ​​ .

- Safari javascript, , . !

+4

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


All Articles