How to cache a page so that when returning "back" it was displayed not in its original form, but before the transition? The point is that the user selects data by the filter and then the URL changes, but if it returns "Back", what would be displayed not the original data, but the ones selected before the transition.

    2 answers 2

    You need to save the page state in some way. When the page status changes, you can change the #hash in the URL, for example http://example.com/page#mode=search&search=foobar . When you go back, the browser will restore including #hash. Then you can use the parameters from #hash to bring the page to the state in which it should be.

      You can use either #hash or localStorage (or cookies) to store the page state, or set Cache-Control (no-store, must-revalidate) if the page state (selected filter) is preserved on the server. More detailed description here:

      How to intercept the button "back" browser?