markoh
4/6/2006 12:39:00 PM
Yep this definitely is the problem with Context.Cache object or web data
caching in general in ASP.NET.
It is easily reproducable using MSDN DynamicImage control (tutorial on MSDN
by Dino Esposito). That same control worked in 1.1 but now sometimes images
are retrieved from cache, sometimes the value in cache is null, which makes
the control useless because few images get loaded others don't or sometimes
none get loaded or all of them.
We would need official statement and solution from MS on this asap.
regards
"Manso" <Manso@discussions.microsoft.com> wrote in message
news:21114551-F902-42AD-AC5B-C3DF5D941D95@microsoft.com...
> Ok, we've now figured out how to work around what seems to be an overly
> aggressive cache scavenging in ASP.NET 2.0. I'm not saying this is a bug
> but
> it's definitely something that has changed since 1.1 and people should be
> aware of because it's damn hard to find because you simply repopulate the
> cache when it gets emptied.
>
> We had the following code
>
> Current.Cache.Insert("config", objConfig, New
> Caching.CacheDependency("c:\mydir\config.xml"))
>
> This code was running fine on 1.1. Cache was never being emptied (unless
> the
> dependant file was changed). I have verified this now by using our logging
> framework. Same code constantly gets reset in 2.0, sometimes just after
> Cache.Insert when stepping through code. This started when we had to swap
> to
> HttpRuntime.Cache but it's the same with HttpContext.Current.Cache - we
> just
> happened to notice it when trying HttpRuntime.Cache because we needed to
> access it from a TimerCallback function.
>
> We changed to
>
> Current.Cache.Insert("config", objConfig, New
> Caching.CacheDependency("c:\mydir\config.xml"),
> Web.Caching.Cache.NoAbsoluteExpiration,
> Web.Caching.Cache.NoSlidingExpiration,
> Web.Caching.CacheItemPriority.NotRemovable, Nothing)
>
> It sticks and works. This is constantly reproducable, we have no resource
> problems and are running on WinXP. Not sure if you have the same problem
> with
> other dependency types.
>
> - Manso
>