Hello friends, today I was working on a project and in the project I need to refresh the current page without loading the cache. So I found the solution and I think it will share with you.
So in this trick, I’ll show you how to hard refresh current page using the javascript code. We just need to add simple one line of code.
You can add this line of code in the element as inline javascript or you can make a function on the event hits. So when the event occur you can call the hard refresh code line.
JavaScript Hard Refresh Current Page
Let’s see the code line what you can use to reload the whole page from server not from the cache. So we will use reload()
function of location
object.
As you see we use the reload()
function and pass the true
parameter to load the page from the server. If you don’t pass the true
parameter then it will load the page from the cache.
So you can use the above function as following code.
When you click on the button then the reload()
function call and force the page to load from the server. You can use this function on any event but not on the window.load and document.ready, becasue it will be infinite.
Also Read: How to Detect IE Browser (Internet Explorer or Edge) in JavaScript?
Being Tricky 😉