If you have a better heading for this question, feel free to edit.
For the longest time, I always used location.reload()to reload the page - this is the most logical thing to do, right?
But I recently noticed that this is not the equivalent of F5, as I originally thought, but more Ctrl + F5. All images and other related files were re-requested from the server when all I wanted to do was reload the page.
I found that I can use location.replace(location.href), and this seems to achieve the effect I want: reload the page, but get the related files from the cache.
Is that ideal? Is there a better way than this? Can I ignore any pitfalls this method may have?
(note: I already have control over the caching of related files, such as scripts, by adding filemtimeas a query string)
source
share