Reload same page when back button pressed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    Reload same page when back button pressed

    i saw some magic web pages .....

    when press back button then the same page again and again reloaded ...

    is it possible in js ......

    plz help me out ...

    thanx in advnace .......
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Changed title.

    Comment

    • AricC
      Recognized Expert Top Contributor
      • Oct 2006
      • 1885

      #3
      Originally posted by dmjpro
      i saw some magic web pages .....

      when press back button then the same page again and again reloaded ...

      is it possible in js ......

      plz help me out ...

      thanx in advnace .......
      So effectively you don't want the users to ever be able to leave?

      Comment

      • UniDyne
        New Member
        • Oct 2005
        • 18

        #4
        They reloaded because of a redirect on the previous page. Double-clicking the back button usually fixes those. No magic involved there - it's actually normal behaviour on large sites that move pages from time to time.

        Comment

        • AricC
          Recognized Expert Top Contributor
          • Oct 2006
          • 1885

          #5
          Originally posted by UniDyne
          They reloaded because of a redirect on the previous page. Double-clicking the back button usually fixes those. No magic involved there - it's actually normal behaviour on large sites that move pages from time to time.
          The worst is MSDN.

          Comment

          • vijith vv

            #6
            You can try using the HttpResponse.Ca che property if that would help:

            Code:
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
            Response.Cache.SetCacheability(HttpCacheability.Public);
            Response.Cache.SetValidUntilExpires(false);
            Response.Cache.VaryByParams["Category"] = true;
            
            if (Response.Cache.VaryByParams["Category"])
            {
               //...
            }
            Or could could block caching of the page altogether with HttpResponse.Ca cheControl, but its been deprecated in favor of the Cache property above:
            Code:
            Response.CacheControl = "No-Cache";
            
            Edit: OR you could really go nuts and do it all by hand:
            
            Response.ClearHeaders();
            Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
            Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
            Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
            Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
            Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1 
            Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1 
            Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1 
            Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.1 
            Response.AppendHeader("Keep-Alive", "timeout=3, max=993"); // HTTP 1.1 
            Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.1

            Comment

            Working...