Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

HttpRuntime.Cache is never null on my dev computer



This is prob not epi releated. But since you all are working with epi maybe some of you have the same issue.

The code is working fine in prod and test.

But on my local computer (Windows 10 latest update, web.config has httpRuntime targetFramework="4.6.2") the cache never expires

If i do this line of code (execute one time)

HttpRuntime.Cache.Insert("test", "test", null, DateTime.Now.AddMinutes(1), Cache.NoSlidingExpiration);

This will never be null.


I expect it to be null after 1 min.

But this one works fine

private static ISynchronizedObjectInstanceCache SyncedCache
= ServiceLocator.Current.GetInstance();

Execute ones

var policy= new CacheEvictionPolicy(TimeSpan.FromMinutes(1), CacheTimeoutType.Sliding);
SyncedCache.Insert("test", "test", policy);

This will be null after 1 min

var thisOneWorks = SyncedCache.Get(cacheKey);


Edited, Nov 21, 2017 10:34

Is it a type-O that you are using sliding in one and nosliding in the other?

Nov 21, 2017 11:14

Here is my Cachehelper. 

public static T Get<T>(string cacheKey, Func<T> getDataMethod, int minutesToCache = 5, bool forceUpdate = false)
if (!forceUpdate && HttpRuntime.Cache[cacheKey] != null)
// -> Found in cache AND we are not forcing update
return (T)HttpRuntime.Cache.Get(cacheKey);
T data = getDataMethod();

if (data != null)
HttpRuntime.Cache.Insert(cacheKey, data, null, DateTime.Now.AddMinutes(minutesToCache), Cache.NoSlidingExpiration);
return data;


public static List<string> GetCurrencyList()
return CacheHelper.Get("CurrencyHelper.GetCurrencyList", () => GetCurrencyListNoCache(), 60);

private static List<string> GetCurrencyListNoCache()
// If i add a log line here it will hit once And never again. If i recycle it will hit

Edited, Nov 21, 2017 11:27

Maybe this is the problem?

I have .net 4.7 on my dev computer

Nov 21, 2017 11:58

Installed .net 4.7.1 and it works again :)

There is cache issues with .net 4.7

Nov 21, 2017 12:11
<p>Thanks for your reply Henrik</p>
Nov 21, 2017 12:12

Well, I did not do anything :)

Great that you solved it and thanks for explaining why here if anyone else got the same thing

Nov 21, 2017 12:53
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.