Re: Programatically remove @OutputCache

Discussion in 'ASP .Net' started by Stewart, Jun 25, 2003.

  1. Stewart

    Stewart Guest

    I orignally posted this question.

    Thanks for your response. I can not check this variable when the page
    is initalised or loaded as for cached pages Init, Load nor any other
    page events are not called.

    Any further ideas?

    Thanks,

    Stewart
    Stewart, Jun 25, 2003
    #1
    1. Advertising

  2. Stewart

    Natty Gur Guest

    OK,

    Maybe I wasn’t clear enough. Before the page init occur the application
    beginrequest event is called. You can check the variable there and use
    the context to get to the response and disable the outputcache.

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
    If
    (!CacheRequired) HttpContext.Current.Response.Cache.SetNoServerCaching
    ();
    }


    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, Jun 25, 2003
    #2
    1. Advertising

  3. Stewart

    Stewart Guest

    Many Thanks!
    Stewart, Jun 26, 2003
    #3
  4. Stewart

    Stewart Guest

    Unfortunately this is still not clearing the @OutputCache either. It
    is going into the SetNoServerCaching() as you can see it in debugger,
    but it is still pulling the page from cache. Strange. Here is my
    code:

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
    EventArgs)
    Dim strCacheItem As String

    strCacheItem = New String(Request.QueryString("ClearCache"))
    If strCacheItem.ToLower = "page" Then
    'clear page cache
    Me.Context.Current.Response.Cache.SetNoServerCaching()
    Me.Context.Response.Cache.SetNoServerCaching()
    Me.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1))
    End If
    End Sub

    Any further ideas?
    Stewart, Jun 26, 2003
    #4
  5. Stewart

    Stewart Guest

    Fixed:

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    Dim strCacheItem As String
    strCacheItem = New String(Request.QueryString("ClearCache"))
    If strCacheItem <> "" Then
    If strCacheItem.ToLower = "page" Then
    'clear page cache by response dependency
    Response.RemoveOutputCacheItem(Request.Path)
    End If
    End If
    End Sub

    Note, this will clear out all cached 'parameter-dependent versions' of a page.
    Stewart, Jun 26, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Natty Gur

    Re: Programatically remove @OutputCache

    Natty Gur, Jun 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    764
    Natty Gur
    Jun 26, 2003
  2. Teemu Keiski

    Re: Programatically remove @OutputCache

    Teemu Keiski, Jul 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    354
    Teemu Keiski
    Jul 2, 2003
  3. Frank Rizzo

    How to remove page from OutputCache

    Frank Rizzo, Feb 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    357
    Frank Rizzo
    Feb 20, 2006
  4. ABCL
    Replies:
    1
    Views:
    518
    Masudur
    Mar 22, 2007
  5. David Lozzi

    programatically clearing the outputcache

    David Lozzi, Dec 3, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    360
    Michael Nemtsev [MVP]
    Dec 4, 2007
Loading...

Share This Page