var counter = 1; $('button').click(function(){ $.ajax({ url: 'index.json', method: 'GET', success: function(res){ $('body').append(JSON.stringify(res)) if (!!(window.history && history.pushState)) { history.replaceState(null, null, '?page=' + counter); } counter++; } }); }); 

A jamb came up on the site, due to the fact that by pressing the button data is loaded via ajax and the browser history is updated via history api via the replaceState method, which rewrites the history.

The problem is that if I press the back button, it shows not the previous page, but the result of the ajax request. That is, it seems as if the result of ajax is recorded in history, although the url is correct

This is in chrome, FF works fine and I see the whole page. I tried to reproduce on a separate html-page - all the buzz in all browsers - did anyone come across this?

If you change the GET request to POST, then all good

As if the story remembers this request GET request (play only in chrome)

    1 answer 1

    It was ajax . It caches get requests. Helped cache: false