Clear html history created by pushState on refresh
If you read the specification of History API for pushState, in step 4 it states
- If the method invoked was the
pushState()
method:
Remove all the entries in the browsing context's session history after the current entry. If the current entry is the last entry in the session history, then no entries are removed.
So depending on what you are trying to do, you could make a special case for when first loading the page and push a state (one you will consider your first), and in doing so clear the forward states of the history.
My idea - override whole history:
for (i = 0; i < 50; i++) {
history.pushState({}, '');
}