Summary
Wolverine.HTTP currently supports [ResponseCache] for client-side cache headers but has no integration with ASP.NET Core's server-side output caching middleware. There's no way to declaratively apply output caching to a Wolverine endpoint.
Proposal
Add output caching support to Wolverine.HTTP via:
- New attribute — e.g.
[WolverineOutputCache] or [CachedResponse] that can be applied to endpoint methods to opt into server-side output caching with policy configuration (duration, vary-by, tags for invalidation)
- New Wolverine.HTTP middleware — code-generated middleware that integrates with ASP.NET Core's
OutputCacheMiddleware infrastructure, handling cache storage and retrieval
- Integration with
[Entity] loader and persistence codegen — the output caching middleware must be aware of existing entity loading patterns. If an endpoint uses [Entity] or other persistence loading attributes, the caching layer needs to:
- Short-circuit entity loading on cache hits (avoid unnecessary DB queries)
- Properly integrate with the code generation pipeline so the cache check runs before persistence loading in the generated handler code
- Tag-based cache invalidation — ability to invalidate cached responses when related data changes (e.g. via message handlers or side effects)
Implementation Considerations
- The code generation must place the cache check before any
[Entity]/persistence loading in the generated pipeline to avoid unnecessary database round-trips on cache hits
- Should support ASP.NET Core's existing output cache policies and tag-based eviction
- Consider how this interacts with multi-tenancy (tenant-specific cache keys)
- Consider interaction with authorization (authenticated vs anonymous caching)
- ETag/conditional request support (304 Not Modified) would be a natural companion feature
Context
All comparable frameworks support output caching:
- Minimal APIs: built-in
.CacheOutput() with policies, tag-based invalidation (.NET 7+)
- MVC:
[OutputCache] attribute with the same middleware
- FastEndpoints: uses ASP.NET Core output caching middleware directly
Output caching can dramatically reduce load for read-heavy endpoints and is a commonly expected feature for production APIs.
🤖 Generated with Claude Code
Summary
Wolverine.HTTP currently supports
[ResponseCache]for client-side cache headers but has no integration with ASP.NET Core's server-side output caching middleware. There's no way to declaratively apply output caching to a Wolverine endpoint.Proposal
Add output caching support to Wolverine.HTTP via:
[WolverineOutputCache]or[CachedResponse]that can be applied to endpoint methods to opt into server-side output caching with policy configuration (duration, vary-by, tags for invalidation)OutputCacheMiddlewareinfrastructure, handling cache storage and retrieval[Entity]loader and persistence codegen — the output caching middleware must be aware of existing entity loading patterns. If an endpoint uses[Entity]or other persistence loading attributes, the caching layer needs to:Implementation Considerations
[Entity]/persistence loading in the generated pipeline to avoid unnecessary database round-trips on cache hitsContext
All comparable frameworks support output caching:
.CacheOutput()with policies, tag-based invalidation (.NET 7+)[OutputCache]attribute with the same middlewareOutput caching can dramatically reduce load for read-heavy endpoints and is a commonly expected feature for production APIs.
🤖 Generated with Claude Code