I'm a mac user and never use IE. But yesterday at work I went onto stack overflow and typed this into the browser using IE 9...
http://stackoverflow.com/questions/824349
And they replaced the URL to this without refreshing the page...
http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page
I could not believe what I saw. Any ideas how stack overflow is able to utilize a functionality that mimics the history API's replace state on a browser that does not support it?
They actually redirect the user with a 301
redirection. Look at the headers:
GET /questions/824349 HTTP/1.1
Host: stackoverflow.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0
[...]
HTTP/1.1 301 Moved Permanently
Cache-Control: public, max-age=60
Content-Type: text/html
Expires: Sat, 08 Jun 2013 19:00:05 GMT
Last-Modified: Sat, 08 Jun 2013 18:59:05 GMT
Location: /questions/824349/modify-the-url-without-reloading-the-page
Vary: *
X-Frame-Options: SAMEORIGIN
Date: Sat, 08 Jun 2013 18:59:05 GMT
Content-Length: 0
It's a 301 Moved Permanently
redirect, i.e. it's done server side. You don't see a refresh because the browser doesn't open the first URL, it redirects right away to the second.
Here's the result on chrome's console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With