-
Notifications
You must be signed in to change notification settings - Fork 67
Random "Accessing expired session" warning #183
Comments
There are some known issues with MemoryCache (and DistributedMemoryCache) over-eagerly removing items due to perceived memory load. See CompactOnMemoryPressure: https://github.com/aspnet/Caching/blob/d417a71d7be76a629336227f3bb75d46bc6cf9a3/src/Microsoft.Extensions.Caching.Memory/MemoryCacheOptions.cs#L21 This has been redesigned for 2.0 RTM |
Thank you for the information. In the meantime we may have found a workaround for v1.1.2. As soon as we invert the lines the problem disappears: This workaround is actually working, we have tried inverting multiple times the lines of code on multiple PCs and whenever we add Mvc after MemoryCache and Session we are never been able to get the "Accessing expired session" warning. I thought only the |
Service registration order can matter if multiple things try to register the same service differently. These differences may explain what you're seeing: The MVC registration uses a shared MemoryCache and shared MemoryCacheOptions. The Caching one uses an isolated MemoryCache and options. Sharing the cache may be worse for you if something else is putting a lot of load on it. |
Thank you @Tratcher for your clarification! |
Hi, I have an application without Authentication.
All the user data is passed by an external portal via http headers on the first request, and I store it in Session.
I have configured the DistributedCache and Session services this way:
services.AddDistributedMemoryCache();
services.AddSession(o => o.IdleTimeout = TimeSpan.FromMinutes(20));
During navigation, the application sometimes loses the session way before the IdleTimeout, and checking the log I can see the “Accessing expired session” warning.
The problem is that it does not happen all the time, it’s totally random. The issue may happen once after 10 correct responses, or it may fail 10 times before succeeding.
It happens only after an Ajax call that returns a big amount of data (JSON format) that is rendered inside a Kendo UI Grid, but the Ajax call is always processed correctly, so there is no way for me to understand if during the next request I will get the "Accessing expired session" warning or not.
It looks like I'm missing a piece of configuration, but no matter what i adjust I still get the same warning with the same random frequency.
The text was updated successfully, but these errors were encountered: