Disabling page caching not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?cHJhZGVlcF9UUA==?=

    Disabling page caching not working

    Hi All,

    Can anyone please explain me why I am not able to disable Browser caching in
    ASP.net by writing the following code

    Response.Buffer = true;
    Response.Expire sAbsolute = DateTime.Now.Su btract(new TimeSpan(1, 0,
    0, 0));
    Response.Expire s = 0;
    Response.CacheC ontrol = "no-cache";

    To test if it is working, I wrote the above code in the page load event
    handler of a ASPX page called Page1.aspx. I added a Button with a click event
    handler which posts the page to a second page Page2.aspx. Now when I press
    back button on the browswer while in Page2.aspx, I get page1.aspx. I should
    be getting page expired error page, but what I have observed is that whenever
    i press back button on the browswer, page1.aspx is freshly loaded (I put
    break on page_load event handler to find this out).

    I also tried to write this code in the page_load event of Page1.aspx instead
    of the four lines of code

    Page.Response.C ache.SetCacheab ility(HttpCache ability.NoCache );

    The above code is also not working. I am using IE 7.0.

    thanks
    pradeep

  • Peter Bromberg [C# MVP]

    #2
    Re: Disabling page caching not working

    I'm not sure I understand why you expect a "page expired" message. If
    caching is disabled, the page would simply be re-requested by the browser,
    exactly as you describe...
    Peter

    "pradeep_TP " <pradeepTP@disc ussions.microso ft.comwrote in message
    news:BF0412EB-BABA-4075-993D-2B88A5FC04E3@mi crosoft.com...
    Hi All,
    >
    Can anyone please explain me why I am not able to disable Browser caching
    in
    ASP.net by writing the following code
    >
    Response.Buffer = true;
    Response.Expire sAbsolute = DateTime.Now.Su btract(new TimeSpan(1, 0,
    0, 0));
    Response.Expire s = 0;
    Response.CacheC ontrol = "no-cache";
    >
    To test if it is working, I wrote the above code in the page load event
    handler of a ASPX page called Page1.aspx. I added a Button with a click
    event
    handler which posts the page to a second page Page2.aspx. Now when I press
    back button on the browswer while in Page2.aspx, I get page1.aspx. I
    should
    be getting page expired error page, but what I have observed is that
    whenever
    i press back button on the browswer, page1.aspx is freshly loaded (I put
    break on page_load event handler to find this out).
    >
    I also tried to write this code in the page_load event of Page1.aspx
    instead
    of the four lines of code
    >
    Page.Response.C ache.SetCacheab ility(HttpCache ability.NoCache );
    >
    The above code is also not working. I am using IE 7.0.
    >
    thanks
    pradeep
    >

    Comment

    • Peter Bromberg [C# MVP]

      #3
      Re: Disabling page caching not working

      I'm not sure I understand why you expect a "page expired" message. If
      caching is disabled, the page would simply be re-requested by the browser,
      exactly as you describe...
      Peter

      "pradeep_TP " <pradeepTP@disc ussions.microso ft.comwrote in message
      news:BF0412EB-BABA-4075-993D-2B88A5FC04E3@mi crosoft.com...
      Hi All,
      >
      Can anyone please explain me why I am not able to disable Browser caching
      in
      ASP.net by writing the following code
      >
      Response.Buffer = true;
      Response.Expire sAbsolute = DateTime.Now.Su btract(new TimeSpan(1, 0,
      0, 0));
      Response.Expire s = 0;
      Response.CacheC ontrol = "no-cache";
      >
      To test if it is working, I wrote the above code in the page load event
      handler of a ASPX page called Page1.aspx. I added a Button with a click
      event
      handler which posts the page to a second page Page2.aspx. Now when I press
      back button on the browswer while in Page2.aspx, I get page1.aspx. I
      should
      be getting page expired error page, but what I have observed is that
      whenever
      i press back button on the browswer, page1.aspx is freshly loaded (I put
      break on page_load event handler to find this out).
      >
      I also tried to write this code in the page_load event of Page1.aspx
      instead
      of the four lines of code
      >
      Page.Response.C ache.SetCacheab ility(HttpCache ability.NoCache );
      >
      The above code is also not working. I am using IE 7.0.
      >
      thanks
      pradeep
      >

      Comment

      • =?Utf-8?B?cHJhZGVlcF9UUA==?=

        #4
        Re: Disabling page caching not working

        I do not want to show the previous page when the user clicks on the back
        button on the browswer. All I want it that when the back button is pressed,
        the standard "page expired" page should be shown.

        You are right, now I understand that if I disable the page caching, the page
        would be requested from the server. But how would i make the browser show
        only the page expired message ?

        thanks
        pradeep

        "Peter Bromberg [C# MVP]" wrote:
        I'm not sure I understand why you expect a "page expired" message. If
        caching is disabled, the page would simply be re-requested by the browser,
        exactly as you describe...
        Peter
        >
        "pradeep_TP " <pradeepTP@disc ussions.microso ft.comwrote in message
        news:BF0412EB-BABA-4075-993D-2B88A5FC04E3@mi crosoft.com...
        Hi All,

        Can anyone please explain me why I am not able to disable Browser caching
        in
        ASP.net by writing the following code

        Response.Buffer = true;
        Response.Expire sAbsolute = DateTime.Now.Su btract(new TimeSpan(1, 0,
        0, 0));
        Response.Expire s = 0;
        Response.CacheC ontrol = "no-cache";

        To test if it is working, I wrote the above code in the page load event
        handler of a ASPX page called Page1.aspx. I added a Button with a click
        event
        handler which posts the page to a second page Page2.aspx. Now when I press
        back button on the browswer while in Page2.aspx, I get page1.aspx. I
        should
        be getting page expired error page, but what I have observed is that
        whenever
        i press back button on the browswer, page1.aspx is freshly loaded (I put
        break on page_load event handler to find this out).

        I also tried to write this code in the page_load event of Page1.aspx
        instead
        of the four lines of code

        Page.Response.C ache.SetCacheab ility(HttpCache ability.NoCache );

        The above code is also not working. I am using IE 7.0.

        thanks
        pradeep
        >

        Comment

        Working...