Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / January 2005

Tip: Looking for answers? Try searching our database.

Ad-Hoc ASCX Cache flushing???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francis Shanahan - 14 Jan 2005 04:42 GMT
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 - 17 Jan 2005 19:58 GMT
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

>I have an ASCX, with this directive:
>
[quoted text clipped - 51 lines]
> has any experience with this. Thanks,
> -fs

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.