I have a few asp.net webforms sites, on a production server, that are suddenly having caching problems. The issue is my cache values are not persisting when using the Cache.Insert method. Using Cache["key"] = value does still work though.
For example, when I set a value like this, it is null when I retrieve it.
HttpRuntime.Cache.Insert("CacheTestVal", "Help Me!" null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
When I set the value like this, I can retrieve the expected value
Cache["CacheTestVal"] = "Help Me!";
I need to be able to set an absolute expiration for the cache value, so I can't use the Cache[""] method. All help is appreciated. Thanks.
Edit: I found that setting the absolute expiration as a UTC datetime does work. I believe the problem is that the server is not converting the absolute expiration to UTC when using DateTime.Now.
HttpRuntime.Cache.Insert("CacheTestVal", "Help Me!" null, DateTime.UtcNow.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
The date/time and timezone are all set as I would expect on the server, but maybe IIS doesn't recognize this, or there is a bad configuration value somewhere?