Groups | Blog | Home
all groups > asp.net caching > january 2005 >

asp.net caching : Ad-Hoc ASCX Cache flushing???


Francis Shanahan
1/13/2005 11:42:00 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

Francis Shanahan
1/17/2005 2:58:52 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@NoSpamTodayThanks.francisshanahan.com> wrote in
message news:uH26fNf%23EHA.600@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button