How Do I prepopulate the outputcache in an asp.net web application?

In the past I have used warm up scripts programmerramblings.blogspot.com/2008/09... A solution like this will basically "ping" ever page. This "ping" will cause your cache to get activated. It will also prevent users from hitting the cold website so the pages will be fully jit'ted by the time they get there Edit: I still don't know how I feel about the smell of the following solution, but how about firing off a web request on application start to each page?

String cachedPages = new string { "..."" rel="nofollow">...", "..."" rel="nofollow">...", ...}; foreach (var url in cachePages) { var request = WebRequest. Create(url); request. BeginGetResponse(null, null); }.

In the past I have used warm up scripts programmerramblings.blogspot.com/2008/09... A solution like this will basically "ping" ever page. This "ping" will cause your cache to get activated. It will also prevent users from hitting the cold website so the pages will be fully jit'ted by the time they get there.

Edit: I still don't know how I feel about the smell of the following solution, but how about firing off a web request on application start to each page? String cachedPages = new string { "..."" rel="nofollow">...", "..."" rel="nofollow">...", ...}; foreach (var url in cachePages) { var request = WebRequest. Create(url); request.

BeginGetResponse(null, null); }.

Yeah, this will work, but it means that the warm up script is not part of the application_start, which is ideally where I'd like it to be. What if IIS gets restarted? I'm in a situation where I don't have control over the box where the website sits, so I'd like everything to be self contained in the server application.

– rhizohm Oct 7 '09 at 20:15 I can only think of hacky type ways to get it on application start. Depending on the pages and the traffic to the site I might create a scheduled task on my local machine to ping the site on a frequent interval. – Bob Oct 7 '09 at 20:21 I have updated my answer to show some simple code to do a warm up from Application start.It seems like it should work, but something doesn't feel right to me.

– Bob Oct 7 '09 at 20:46 Hmm, that could work, although it feels a bit recursive or something -- also I don't know the limitations on outbound http requests from the server. I think there's a throttle there. Will investigate and respond.

– rhizohm Oct 7 '09 at 22:26.

Obviously you're keen on a solution now, but take a look at what's coming in ASP. NET 4. There are two new additions which may well help you out.

The first is the ability to specify "warm up" logic for ASP. NET apps - you configure this in the web. Config and optionally tell it to run code that implements IProcessHostPreloadClient.

See here for details: weblogs.asp.net/scottgu/archive/2009/09/... The second is that you'll get a proper provider model for output caching. Until now, there's only been one option: caching in the worker process. So every time there's a recycle, you lose your cache (and you are of course limited by memory constraints).

In ASP. NET 4, you get disk based caching out of the box too. See here for details: asp.net/learn/whitepapers/aspnet40/#_TOC1_2.

I don't believe you get disk based caching out of the box. Microsoft never released a disk-based cache - you have to write your own implementation of System.Web.Caching. OutputCacheProvider.

– Tom Lianza Jun 14 at 23:18.

I'm not sure if you can actually cache a page dynamically as you are saying, but you can add objects to the cache in the Global. Asax file. Void Application_Start(object sender, EventArgs e) { }.

Well, in this scenario, I happen know what they are going to request. Yes, I know I can add the cache variable, but I want to add to the outputcache. – rhizohm Oct 7 '09 at 20:16 As he mentioned, he's looking to prepopulate the cache with a set of common values--things he knows will be requested.

This way, when a user actually hits the site with that request, that user doesn't experience a lag while the item gets fetched and cached. – StriplingWarrior Oct 7 '09 at 20:17.

Obviously you're keen on a solution now, but take a look at what's coming in ASP.NET 4. There are two new additions which may well help you out. The first is the ability to specify "warm up" logic for ASP.NET apps - you configure this in the web.

Config and optionally tell it to run code that implements IProcessHostPreloadClient. The second is that you'll get a proper provider model for output caching.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions