-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
As part of f99b482 code is DistributedSession.CommitsAsync was modified to check IsAvailable.
| public async Task CommitAsync(CancellationToken cancellationToken = default) |
IsAvailable always loads session from backing store and loads it in synchronous way.
| public bool IsAvailable |
On the other hand SessionMiddleware always calls DistributedSession.CommitAsync to save session. This means that in 6.0 session is always loaded even if application code did not touch it at all. In case of using Redis as backing store this incurs two Redis calls on each RazorPage rendered.
| await feature.Session.CommitAsync(); |
In the past (5.0) when session was not touched DistributedSession._isModified prevented session data from being loaded when session was not modified.
| if (_isModified) |
@pranavkm Could you tell why IsAvailable was moved?
Expected Behavior
Don't loading session data from backing store when session data is not modified by app code.
.NET Version
6.0.300