views:

68

answers:

1
window.location.reload()
history.go(0)
window.location.href=window.location.href

I noticed a website commenting that all 3 of these methods could be used to reload a page. Not content to trust it, I tried all 3 methods in IE8, FF3, and Opera 10. I noticed firefox performed a cache reload instead of a true reload for history.go(0), but otherwise saw no differences. However, I thought I'd ask the community here what differences they were aware of between these methods.

+4  A: 

The main difference between window.location.reload() and window.location.href=window.location.href is, that the first one will resend POST data if exists (the browser will ask you if you want to reload the page and resend the data), the second will just change the URL ignoring any POST data.

Regarding history.go(0), we are using the history object, so the browsers may use cached version of the page, stored somewhere in memory.

Rafael