ASP.NET 2.0 Cache Issue


We have been using a DynamicImage control to display images stored in the database, it makes use of the Cache feature to store the byte stream of the image.  Recently we noticed that we were getting "red X’s" displayed on our site for no specific reason, after a bit of research (I contacted MS) and searching the web it seems that the Cache is a bit agressive and the cache was getting flushed.  This occurred when we upgraded from Beta 2 to RTM on our x32 bit platform, but since upgrading to our x64 platform it occurred on a much more frequent basis.

Microsoft is aware of the problem but no fix exists at the moment, the work around I found below seems to address the issue we were experiencing.

 

This is the line of code I changed to address the problem:

Before:

Page.Cache.Add(StorageKey,
data,
null,
Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(5),
CacheItemPriority.High,
null);

After:

Page.Cache.Insert(StorageKey,
data,
null,
Cache.NoAbsoluteExpiration,
Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable,
null);

 

The DynamicImage control is from Dino Esposito’s MSDN column Cutting Edge located here.  When Mirosoft removed the DynamicImage control from ASP.NET 2.0 we used this version instead for 2.0.

 

Technorati tags:

About wesmacdonald

Wes MacDonald is a Visual Studio ALM MVP, PSD, MCT and a Principal Consultant for LIKE 10 INC., a SharePoint Server, Visual Studio and Team Foundation Server Consulting Firm providing premium support and guidance services.

One Response to “ASP.NET 2.0 Cache Issue”

  1. Thank you!I thought the cache kept on flushing. Now I have the solution.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: