Question
How to cope with refreshing page with JS History API pushState
A small website I was creating (more like fiddling) uses AJAX to load each page. Previously I was changing the hash of the url, this worked great but was ugly, and the user could refresh the page, and it would stay on the same page.
Now I have switched to using pushState in the JS History API, which looks much better, and the back and forward work, but refreshing does not. For example:
Going to: http://example.com/page2
goes to a 404 as there is no real page called page 2. But if I click on the button which uses the pushState method to change the url, it works as it should.
How can allow refreshes, and permalinks with the new History API?
(And how do search engines treat this, seeing as Google had to create a way of indexing hash urls, by making the developer switch to #!
, is it possible they will do something similar for the history api in the future?)