Skip to content

Configurable Output Caching via VariableService #18

@danlorb

Description

@danlorb

Configurable Output Caching via VariableService

🎯 Summary

  • Goal: Integrate ASP.NET Core Output Caching into the xSDK framework, leveraging the internal VariableService for dynamic, configuration-driven policy management.
  • Stack: Microsoft.AspNetCore.OutputCaching, xSdk.Extensions.Variable, .NET 10.0, IConfiguration

🛠 Roadmap (Pomodoro Tasks)

  • Task 1: Define the OutputCacheSettings POCO class within the xSDK namespace to map VariableService configuration keys (e.g., xsdk:cache:output).
  • Task 2: Implement a VariableService binder to hydrate OutputCacheOptions from the centralized configuration store during the AddXSdk() startup sequence.
  • Task 3: Create a ServiceCollection extension that registers AddOutputCache() only if VariableService.Get<bool>("Cache:Output:Enabled") returns true.
  • Task 4: Develop a PolicyFactory that iterates through VariableService lists to dynamically register named policies (e.g., Default, ShortLived, NoAuth).
  • Task 5: Implement a custom IOutputCachePolicy that respects xSDK-specific headers or tenant IDs retrieved via the VariableService environment context.
  • Task 6: Hook into the IApplicationBuilder pipeline to inject UseOutputCache() at the technically correct position (after Routing, before Auth/Endpoints).
  • Task 7: Add a VariableService watcher or reload token integration to allow updating cache durations without restarting the application.
  • Task 8: Create an internal xSDK attribute [XSdkOutputCache(PolicyName)] that acts as a wrapper to provide better IntelliSense and framework-specific defaults.

🔍 Acceptance Criteria

  • Output Caching is togglable via VariableService at runtime or startup.
  • Named policies defined in the VariableService JSON/Environment are correctly registered in the DI container.
  • The middleware order ensures that xSDK's internal VariableService updates are processed before cache lookup if necessary.
  • Technical validation: Responses are cached according to the expiration values defined in the Variable store.

⚠️ Constraints & Out-of-Scope

  • Dependency: Must rely strictly on the xSdk.Extensions.Variable pattern for configuration, avoiding direct IConfiguration access where possible.
  • Scope: Initial implementation focuses on the In-Memory provider. Distributed stores (Redis) are deferred to a separate Epic.

💡 AI-Suggestions

  • Dynamic Tags: Use VariableService to define "Invalidation Groups" so that changing a single variable value can trigger a BasePolicy cache eviction.
  • Telemetry: Integrate ILogger within the policy execution to track Cache Hits/Misses specifically for xSDK-managed endpoints.

📚 Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions