IsolatedCaches disappears randomly

This answer was largely generated by Claude, but is correct:

The most likely cause is memory pressure eviction. Umbraco’s IsolatedCaches uses System.Runtime.Caching.MemoryCache under the hood, which automatically evicts items when the system is under memory pressure; silently, with no errors or logs.

A few things to check:

Don’t treat the cache as reliable storage. Always code for the cache-miss case. Instead of checking once at startup, use a pattern that repopulates on demand:

  var cache = appCache.IsolatedCaches.GetOrCreate<ItemStatus>();
  var result = cache.GetCacheItem(CacheLoadedKey, () =>
  {
      // This factory runs when the item is missing
      return LoadItemStatus();
  });
  1. This way, if the item gets evicted, it’s automatically recreated on next access.
  2. Silent app pool recycles. IIS recycles app pools on a schedule (default: every 29 hours), on memory limits, and on other triggers. These don’t always show up in logs. Each recycle wipes all in-memory caches.
  3. Cache priority. If you’re using InsertCacheItem without specifying a priority, the item is eligible for eviction. You won’t get a warning when this happens.

The fix is to never assume the cache is populated, always provide a fallback/factory to rebuild the data when it’s missing.