Skip to content

OutputCache - Racing condition returns empty response when locking enabled #52310

@FP3ixoto

Description

@FP3ixoto

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When there's a racing condition on OutputCache, with "Locking" enabled, and the first request to hit the OutputCache middleware is cancelled by the client, the middleware resolves the second request to an empty response.

I suspect that the cancelled request ends up caching an empty response and that's the one served on the subsequent requests.

Note that it only happens with the locking feature enabled.

Expected Behavior

The OutputCache middleware should not cache the cancelled request, empty response, and the successful request should return content.

Steps To Reproduce

Minimal repo: https://github.com/FP3ixoto/OutputCacheIssue

Exceptions (if any)

No response

.NET Version

7.0.404; 8.0.100

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresinvestigate

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions