Automatic expiration cache time

2

I am using the function below to store the cache was working normal, but now when add the time of 60min is as if it expired automatic, now if I enter a time greater like 181min the cache is maintained.

If anyone can help me, I'm grateful.

HttpContext.Current.Cache.Insert(chave,
                valor,
                null,
                DateTime.Now.AddMinutes(60),
                Cache.NoSlidingExpiration);
    
asked by anonymous 17.07.2017 / 22:50

1 answer

1

This may be due to a problem with timezones.

Instead of

DateTime.Now.AddMinutes(60)

Prefer

DateTime.UtcNow.AddMinutes(60)
    
24.07.2017 / 23:31