caching

Configure HybridCache and output caching for .NET 10 web APIs.

224|87|Updated Dec 15, 2018
One-click install
npx skills add https://github.com/Resgrid/Core --skill caching-resgrid
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: caching
Source: https://github.com/Resgrid/Core/tree/main/.opencode/skills/caching
Command: npx skills add https://github.com/Resgrid/Core --skill caching-resgrid

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Caching reduces slow repeated reads and lowers database load by serving frequently requested data from faster storage while keeping it accurate via TTLs and invalidation.

Core Features & Use Cases

  • HybridCache-based caching: Use .NET 9+ HybridCache with built-in L1/L2 layering and stampede protection for common read-heavy scenarios.
  • Cache invalidation on mutation: Remove or evict cached entries when data changes so users see fresh results.
  • Output caching for full HTTP responses: Cache entire responses for static or public endpoints, using policies and tags for eviction.
  • Cache-aside (legacy) guidance: Prefer HybridCache over manual IDistributedCache cache-aside unless integrating with existing distributed cache code.

Quick Start

Use the caching skill to design a HybridCache strategy for your read endpoint, including explicit TTLs and mutation-time invalidation.

Frequently Asked Questions about caching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement read-through caching in a .NET web API to reduce database load?

Read-through caching in a .NET web API is implemented using HybridCache to serve frequently requested data from faster storage. It provides built-in L1/L2 layering and stampede protection to reduce slow repeated reads and lower database load.

What is the best way to invalidate cached entries when data changes in a .NET service?

Cache invalidation on mutation is the best way to keep cached data accurate in a .NET service. You remove or evict cached entries when data changes so users see fresh results, paired with explicit TTLs for automatic expiration.

How does HybridCache protect against cache stampedes in high-traffic .NET applications?

HybridCache protects against cache stampedes in high-traffic .NET applications by providing built-in stampede protection. It serializes concurrent requests for the same cache key, preventing multiple requests from simultaneously hitting the slow data store.

Can I cache full HTTP responses in a .NET web API using output caching policies?

You can cache full HTTP responses in a .NET web API using output caching policies and tags. This approach caches entire responses for static or public endpoints and uses tags for targeted eviction when underlying data changes.

Should I use HybridCache or manual IDistributedCache for cache-aside patterns in .NET?

You should use HybridCache over manual IDistributedCache for cache-aside patterns in .NET. Prefer HybridCache for new development unless you are specifically integrating with existing distributed cache code that requires manual management.

Why should I avoid caching mutating operations in my .NET application?

You should avoid caching mutating operations in your .NET application to prevent serving stale or incorrect data. Safe caching patterns require explicit TTLs and only apply to read-heavy scenarios, ensuring data accuracy through proper invalidation.