Add output cache policy for authenticated responses#79
Merged
IeuanWalker merged 4 commits intomasterfrom Jan 27, 2026
Merged
Conversation
Introduces AllowAuthenticatedCachePolicy to enable safe output caching of authenticated responses in Minimal APIs. Adds an extension method to OutputCachePolicyBuilder for easy registration. Ensures only 200 OK responses without Set-Cookie headers are cached. Applies [ExcludeFromCodeCoverage] to new and updated classes.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces output caching capabilities for authenticated responses in Minimal APIs by adding a new AllowAuthenticatedCachePolicy class and a corresponding extension method AllowCachingAuthenticatedResponses() for OutputCachePolicyBuilder. The implementation provides basic output caching that prevents caching of responses with cookies or non-200 status codes.
Changes:
- Added
AllowAuthenticatedCachePolicyimplementingIOutputCachePolicyto control cache behavior based on response characteristics - Added
OutputCachePolicyBuilderExtensionswithAllowCachingAuthenticatedResponses()method for easy policy registration - Added
[ExcludeFromCodeCoverage]attribute toRouteHandlerBuilderExtensions(housekeeping)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/IeuanWalker.MinimalApi.Endpoints/AllowAuthenticatedCachePolicy.cs | New output cache policy implementation that enables caching for 200 OK responses without Set-Cookie headers |
| src/IeuanWalker.MinimalApi.Endpoints/Extensions/OutputCachePolicyBuilderExtensions.cs | New extension method to register the cache policy with OutputCachePolicyBuilder |
| src/IeuanWalker.MinimalApi.Endpoints/Extensions/RouteHandlerBuilderExtensions.cs | Added [ExcludeFromCodeCoverage] attribute to match other extension classes in the project |
src/IeuanWalker.MinimalApi.Endpoints/Extensions/OutputCachePolicyBuilderExtensions.cs
Show resolved
Hide resolved
src/IeuanWalker.MinimalApi.Endpoints/Extensions/OutputCachePolicyBuilderExtensions.cs
Show resolved
Hide resolved
Added detailed XML documentation comments to extension methods across the IeuanWalker.MinimalApi.Endpoints namespace. This improves code readability and enhances IntelliSense by describing method purposes, parameters, type parameters, return values, and exceptions. No functional changes were made.
src/IeuanWalker.MinimalApi.Endpoints/Extensions/OutputCachePolicyBuilderExtensions.cs
Show resolved
Hide resolved
src/IeuanWalker.MinimalApi.Endpoints/AllowAuthenticatedCachePolicy.cs
Outdated
Show resolved
Hide resolved
Updated the comment to specify that only successful 200 OK responses are cached, removing the ambiguous "by default" wording. No changes were made to the caching logic itself.
Updated Dictionary initializations to use C# collection expression syntax ([]) for brevity and clarity. Removed unnecessary IDE0130 pragma directives and streamlined the namespace declaration in AllowAuthenticatedCachePolicy.cs.
SummarySummary
CoverageExampleApi - 97%
IeuanWalker.MinimalApi.Endpoints - 87.2%
IeuanWalker.MinimalApi.Endpoints.Generator - 95.9%
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces AllowAuthenticatedCachePolicy to enable safe output caching of authenticated responses in Minimal APIs. Adds an extension method to OutputCachePolicyBuilder for easy registration.