Groups | Blog | Home
all groups > asp.net caching > may 2004 >

asp.net caching : Manually refreshing the Cache


Jay
5/6/2004 12:04:15 PM
I am using Page Output Caching by using:

<%@ OutputCache Duration=3D"6000" VaryByParam=3D"None" Location=3D"Any" =
%>



I would like to force caching to refresh all pages or specified pages in =
my website. I realize there are various ways of setting the time limit, =
etc. for a cache. Basically I want some pages to be cached "forever" =
but I need to be able to manually force a refresh of all pages by =
running an admin page which executes code that refreshes all pages. =20

The only way that I have been able to force a refresh is to stop the =
website using IIS or reboot the PC. Even in some cases making a change =
in the code of the page and recompilijng did not seem to refresh the =
cache.

Thanks for you help.

Anders Borum
5/9/2004 12:03:06 AM
Hello!

If you have a list of the pages to be evicted from the cache (such as a
hierarchical tree representing the navigation structure), you could do a
iteration on top of that and evict the pages explicitly one by one.

The ASP.NET framework allows for eviction of cached pages programatically!

--
venlig hilsen / with regards
anders borum
--

Jay
5/9/2004 11:51:19 PM
Thanks, but I need a little more help than this.

I am thinking that there are two steps I need to do.

1) Determine what subclasses of System.Web.UI.Page are in my project =
using reflection.
2) For each subclass refresh the output page cache.

I do not know how to do either of these steps.

If I have page in my project called Login how do I refresh the output =
page cache? The only think I know how to do is something like =
Page.cache.remove("foo"), which is an instance method that only removes =
the cached item "foo". I want to programatically refresh the page =
output cache for page Login.

How do I determine what subclasses of System.Web.UI.Page are in my =
project.

Hope this is clear.

Victor _
5/28/2004 7:46:47 AM



Not sure if this will still help you or not but I was looking to do
something similar. I have a page with 3 user controls on it. Each of
the user controls are cached but I wanted to force a refresh on each
user control independently. Here is what I did:
1) Added varybyparam="rptRefresh" to <%@ OutputCache duration="100"
varybyparam="rptRefresh" %>
2) Added a button to the page where the user control is included. When
this button is clicked I redirect to the same page but set a parameter
on the query string called rptRefresh equal to anything. This forces
the user control to refresh. Any time rptRefresh changes values on the
query string the user control will refresh.

Hope this helps.

By the way, I noticed varybycontrol is similar (but references a
control), however, I read this requires overriding before it will work.

--Victor


*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button