Nope. You canβt change the history in browsers by design, imagine what the security implications will be? For example, you can insert something into history and give history.back () to send the user to where you want!
You must handle the back-button elements on the server side of the sessions using some state controller.
Add: when the user clicks the back button, the page is retrieved from cahce or from the server, depending on the header information, etc. The browser has already rendered the page whenever your code starts working. Then, changing the location object will result in additional loading / reloading of the page. If you KNOW that the identifier is invalid, there is no need to remove it from the location hash, you can process it within the server code.
source share