A
A
Alexander2021-06-24 12:09:49
JavaScript
Alexander, 2021-06-24 12:09:49

Why doesn't the browser reload pages when moving back through history?

I update the page by ajax adding a new state to the history like this: But if I press the browser's Back button, the browser simply changes the URL to the old one, but does not update the page to it (does not reload it). Type he remembers that the page was not updated. How can I make the page refresh happen? I don't mean to write js, which will also refresh the page via ajax (I know how to do it), but how to force the browser to refresh when moving back through the history.
history.pushState('', title, url);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey delphinpro, 2021-06-24
@delphinpro

https://developer.mozilla.org/ru/docs/Web/API/Wind...
Catch the event and update the page with ajax.

R
rPman, 2021-06-24
@rPman

Perhaps the browser behaves according to the data caching headers specified on the
Doubtful internal content page (for example, included images).
I foresee the question, why is it reloaded if you re-open the page manually? - because this behavior has been changed, and in this case, all scripts and styles will be reloaded only if caching is correctly configured there (which is why novice web developers constantly fall for - changed the code on the site, reopened the page, and the code there is old).
ps I really liked the old opera with the presto engine for this behavior, when you press back, the browser ignores any cache settings and is guaranteed not to climb on the server, showing the content as quickly as possible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question