How to refresh a page that is not loaded?
First of let us understand the heading of my post ;) If a page is already loaded in the browser, there are several methods to refresh it. You will find them all over the internet.
For example, you can use:-
- <equiv="refresh" content="5">
- location.reload(true)
- javascript:history.go(0)
- etc.
Now you will ask this scenario happens in most of the sites and they all work perfectly fine. The reason is that in most of the sites, when they redirect you after successful login, to page A, they change the url of A a little bit. That is mostly you will find that after you login, there will be some sid, or username appended to the url. That concatenation makes this url not same a A and so browser loads it all over again and the site seems to be working fine.(though the site maker has no idea about all this and was just lucky).
But I have a site where the url of page A does not changes. There are some restrictions and the url of Page A has to remain exactly same. So how do I solve the problem? I searched all over net but couldn't find.(though there must be some solution). But right now I am using this method:-
<html>
<body onLoad="document.form1.submit();" >
Login successful. You are being redirected to the page requested by you.
<form method="post" action="URL of the page to redirect to" name="form1">
</form>
</body>
</html>
Note that the above thing will ask the browser to use POST method. And browser knows that pages fetched with POST method are dynamic and it can't rely on cache. So it won't rely on cache and ask a copy of the page again from the server. Thats it.
PS: Even if the urls are same, browser will sometimes fetch the new copy from the server. This is just my observation. Because in my lab, I had no problem with the simple redirection. But I found that at few other places the cache copy was being used. So I had to use the post method. I guess this all depends on browser settings and proxy settings.
PS: The above problem happened with me with my IIIT LAN Browser project.
No comments:
Post a Comment