You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes. The bug results in incorrect cache expiration checks when the application runs in a time zone different from UTC, leading to stale or prematurely expired cache entries.
Minimal repro steps
Create a web application project targeting .NET Framework 4.6.2.
Decorate an endpoint with the OutputCacheAttribute class, using Duration=3600 (1 hour).
Ensure the project is running in a time zone that is not UTC (e.g., UTC+3, as in Turkey).
Implement caching logic in a class that uses OutputCacheModuleAsync.
Make a request to the cached endpoint.
Expected result
The cache entry should remain valid for the full duration of 1 hour (3600 seconds) as specified, regardless of the server's time zone, and the endpoint response should come from the output cache.
Actual result
Cache entries are prematurely invalidated or stale data is served due to incorrect time zone handling, resulting in responses not coming from the output cache.
Further technical details
The root cause is the use of DateTime.Now for comparison instead of DateTime.UtcNow, which leads to incorrect evaluations of cache expiry in applications running in non-UTC time zones (e.g., Turkey UTC+3).
Functional impact
Yes. The bug results in incorrect cache expiration checks when the application runs in a time zone different from UTC, leading to stale or prematurely expired cache entries.
Minimal repro steps
Expected result
The cache entry should remain valid for the full duration of 1 hour (3600 seconds) as specified, regardless of the server's time zone, and the endpoint response should come from the output cache.
Actual result
Cache entries are prematurely invalidated or stale data is served due to incorrect time zone handling, resulting in responses not coming from the output cache.
Further technical details
The root cause is the use of DateTime.Now for comparison instead of DateTime.UtcNow, which leads to incorrect evaluations of cache expiry in applications running in non-UTC time zones (e.g., Turkey UTC+3).
AspNetOutputCache/src/OutputCacheModuleAsync/OutputCacheHelper.cs
Line 1063 in 8c37dd1
The problem is caused by the line above.
The text was updated successfully, but these errors were encountered: