Prevent many different MVC URLs from filling ASP.NET Cache?

Well I thought it over (Teun and I work at the same company), and we have two options as far as I can tell: Do nothing. This article contains a comment from one asp. Net team guy, and it shows a couple of ways to prevent the cache from growing and growing: forums.asp.net/p/985551/3297967.aspx#329... yet doesn't solve the problem of writing a cache entry for each possible route but guarantees that the cache won't throw some out of memory exception Solve the problem with a workaround, use querystring parameters instead of fixed routes (/controller.

Mvc? Action=X¶ms=Y instead of controller. Mvc/action/params).

This way only controller. Mvc gets cached After all, I don't think this really is a problem.

Well I thought it over (Teun and I work at the same company), and we have two options as far as I can tell: Do nothing. This article contains a comment from one asp. Net team guy, and it shows a couple of ways to prevent the cache from growing and growing: forums.asp.net/p/985551/3297967.aspx#329..., yet doesn't solve the problem of writing a cache entry for each possible route but guarantees that the cache won't throw some out of memory exception.

Solve the problem with a workaround, use querystring parameters instead of fixed routes (/controller. Mvc? Action=X¶ms=Y instead of controller.

Mvc/action/params). This way only controller. Mvc gets cached.

After all, I don't think this really is a problem.

2 Option 2 seems rather lame, as it kills one of the nicest and most visible features of the ASP. NET mvc framework. In our case, it wouldn't matter as we have an ISAPI rewriting dll in place as well.

But it still seems like a lame solution. – Teun D Sep 15 '09 at 6:45.

Our website uses ASP.NET MVC for a part of the pages in it. These URLs typically have the form http://oursite/detail. Mvc/12345/pictures/ In this URL, the 12345 is an ID in the database.

We have several hundred thousands objects for which we show detail pages. Recently we noticed a rise in the memory use for the site, so I investigated a bit. We made a memory dump of the production site and found that a significant amount of the total memory use was cause by strings in Cache of the form "dmachine/webroot/1/site/detail.

Mvc/12345/pictures/" and "H:\site\detail. Further investigation and heavy use of Reflector has showed that these strings are stored in the ASP.NET Cache in the form of a System.Web. This is created by ConfigurationManager when it reads information from the web.

It calls HttpContext.GetSection() --> HttpContext. GetConfigurationPathData() --> CachedPathData. Eventually, in CachedPathData.

GetConfigPathData, the virtual path is determined for the requested path and this is cached in the ASP.NET Cache without expiration. Now the trouble is that we have millions of different URLs, and for each path the Configuration system stores a number of strings (configPath, virtual path, physical path) in cache. Over time, this information consumes several hundreds of MB, allmost all of the data in cache.

I assume that when memory gets scarce, these entries will be removed, but in operations they don't trust processes that grow and grow. It also seems very inefficient. Is there a way to tell the HttpContext not to cache this information for each unique URL?

Or maybe we can map the request path to a simpler URL first and have that used to select the correct web.

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