-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OutputCache configuration - policy validation #52419
Comments
like #45684 |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
@sebastienros Have you seen this yet? Do you think it's a good idea? |
My naive response would be to add a Note that the API suggestion seems to be a copy-paste of the RateLimiting one since it's referring to Update: API suggestion has been fixed |
API Review Notes:
API Approved! namespace Microsoft.AspNetCore.OutputCaching;
+ public interface IOutputCachePolicyProvider
+ {
+ ValueTask<IOutputCachePolicy?> GetPolicyAsync(string policyName);
+ } |
I'm working on it |
Done #57362 |
Background and Motivation
The ASP.NET Core output caching middleware is great, but "limited" in terms of policy validation. Let's start with some code that you can write today in .NET 7:
There is no way to validate that customPolicy actually exists. This is useful when configuring multiple routes from configuration such as is the case for YARP. See microsoft/reverse-proxy#2328
Proposed API
It would be preferred to something similar to IAuthorizationPolicyProvider implemented via DefaultAuthorizationPolicyProvider and ICorsPolicyProvider implemented via DefaultCorsPolicyProvider
OutputCacheOptions.NamedPolicies is internal hence this feature cannot be added in another library or the final application.
Usage Examples
See YARP: https://github.com/microsoft/reverse-proxy/blob/02435e0e2eb3e757fc928d9157cfcc7f2859910b/src/ReverseProxy/Configuration/RouteValidators/OutputCachePolicyValidator.cs#L27-L33
Alternative Designs
None
Risks
None
The text was updated successfully, but these errors were encountered: