close

How to force reloading a page when using browser back button?

Hello Guys, How are you all? Hope You all Are Fine. Today we are going to learn How to force reloading a page when using browser back button? in javascript. So Here I am Explain to you all the possible methods here.

Without wasting your time, Let’s start This Article.

How to force reloading a page when using browser back button ?

  1. How to force reloading a page when using browser back button ?


    to force reloading a page when using browser back button Since performance.navigation is now deprecated, you can try this:
    var perfEntries = performance.getEntriesByType("navigation"); if (perfEntries[0].type === "back_forward") { location.reload(true); }

  2. How to force reloading a page when using browser back button ?

    to force reloading a page when using browser back button Since performance.navigation is now deprecated, you can try this:
    var perfEntries = performance.getEntriesByType("navigation"); if (perfEntries[0].type === "back_forward") { location.reload(true); }

Method 1

Since performance.navigation is now deprecated, you can try this:

var perfEntries = performance.getEntriesByType("navigation");

if (perfEntries[0].type === "back_forward") {
    location.reload(true);
}

Method 2

An alternative that solved the problem to me is to disable cache for the page. That make the browser to get the page from the server instead of using a cached version:

Response.AppendHeader("Cache-Control","no-cache, no-store, must-revalidate");
Response.AppendHeader("Pragma", "no-cache");
Response.AppendHeader("Expires", "0");

Summery

It’s all About this article. Hope all method helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you? Thank You.

Leave a Comment