HighTechTalks DotNet Forums  

Ad-Hoc ASCX Cache flushing???

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss Ad-Hoc ASCX Cache flushing??? in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Francis Shanahan
 
Posts: n/a

Default Ad-Hoc ASCX Cache flushing??? - 01-13-2005 , 11:42 PM






I have an ASCX, with this directive:

<%@ OutputCache Duration="50000" VaryByParam="ctype"
VaryByCustom="contentlist" Shared="true" %>

in my Global.asax I have this handler for the varybyCustom

public override string GetVaryByCustomString(HttpContext context, string
arg) {
if(arg.ToLower() == "contentlist") {
string strReturn = "b";// so it's not blank

// Now check
HttpCookie cookie = context.Request.Cookies["dictionize"];
if(cookie != null) {
string tmp = cookie.Value.ToString();
strReturn += tmp;
}
return strReturn;
}

// Otherwise cache as normal
return base.GetVaryByCustomString(context, arg);
}

My querystring has a parameter "ctype" which should generate a different
version of the ASCX.
I print the current time in both the Page and the ASCX so that I can figure
out what's going on (cached or not cached).
The Control is NOT cached consistently.
It should cache for 50000 seconds no?
Whenever I go to the page, a the time on the Page (dynamic) matches the time
on the control (dynamic the first time it's cached then static after that).
Subsequent requests show that the control is then being cached. (The times
no longer match).
Then after a few mins, not 50,000 seconds, the time gets updated again
telling me that the ASCX was refreshed, as if the cache had been flushed?

What's going on? Why does the new version get generated, it seems like it's
being generated per SESSION and then just cached for the duration of the
session.

You can see it in action at http://www.FrancisShanahan.com
The control is the main part of the page, the timestamp is displayed at the
top of the middle and the top right of the page.

I even put some debugging code in the Application OnStart to see if asp_net
was restarting on the server without my knowledge but this is not the case.

Can anyone shed some light on this topic? All "Google" resources are just
throwing up the same very basic how-to articles. Doesn't seem like anyone
has any experience with this. Thanks,
-fs



Reply With Quote
  #2  
Old   
Francis Shanahan
 
Posts: n/a

Default Re: Ad-Hoc ASCX Cache flushing??? - 01-17-2005 , 02:58 PM






Just to close this out:
The solution (at least I think it's solved) was
ApplicationOnStart WAS firing, turns out my aspnet_wp was recycling every so
often.
To figure out why I conducted a full code review and added an error handler
which unwound an Exception into HTML which was then sent to me from the
Catch block of all my code.
This helped me fix 2 unhandled exceptions which needed to be tidied up.
Unfortunately this did not solve the issue of my recycling application
object.
Turns out my host (webhost4life) was very gracious and both turned off virus
scanning of my web.config file and moved my application to it's own pool.
This has resulted in no more recycling and proper caching, at least so far.

Fingers crossed.
-fs


"Francis Shanahan" <fs (AT) NoSpamTodayThanks (DOT) francisshanahan.com> wrote in
message news:uH26fNf%23EHA.600 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Quote:
I have an ASCX, with this directive:

%@ OutputCache Duration="50000" VaryByParam="ctype"
VaryByCustom="contentlist" Shared="true" %

in my Global.asax I have this handler for the varybyCustom

public override string GetVaryByCustomString(HttpContext context, string
arg) {
if(arg.ToLower() == "contentlist") {
string strReturn = "b";// so it's not blank

// Now check
HttpCookie cookie = context.Request.Cookies["dictionize"];
if(cookie != null) {
string tmp = cookie.Value.ToString();
strReturn += tmp;
}
return strReturn;
}

// Otherwise cache as normal
return base.GetVaryByCustomString(context, arg);
}

My querystring has a parameter "ctype" which should generate a different
version of the ASCX.
I print the current time in both the Page and the ASCX so that I can
figure out what's going on (cached or not cached).
The Control is NOT cached consistently.
It should cache for 50000 seconds no?
Whenever I go to the page, a the time on the Page (dynamic) matches the
time on the control (dynamic the first time it's cached then static after
that).
Subsequent requests show that the control is then being cached. (The times
no longer match).
Then after a few mins, not 50,000 seconds, the time gets updated again
telling me that the ASCX was refreshed, as if the cache had been flushed?

What's going on? Why does the new version get generated, it seems like
it's being generated per SESSION and then just cached for the duration of
the session.

You can see it in action at http://www.FrancisShanahan.com
The control is the main part of the page, the timestamp is displayed at
the top of the middle and the top right of the page.

I even put some debugging code in the Application OnStart to see if
asp_net was restarting on the server without my knowledge but this is not
the case.

Can anyone shed some light on this topic? All "Google" resources are just
throwing up the same very basic how-to articles. Doesn't seem like anyone
has any experience with this. Thanks,
-fs





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.