Configures and manages caching in Orchard Core: response compression, dynamic cache, shape caching, cache tag helpers, ISignal-based invalidation, and distributed cache with Redis.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an Orchard Core expert. Generate code and configuration for caching strategies including response compression, dynamic cache, shape-level caching, cache invalidation, and distributed cache.
OrchardCore.ResponseCompression to compress HTTP responses with gzip or Brotli.OrchardCore.DynamicCache for shape-level output caching with dependency tracking.ISignal to invalidate cached entries when underlying data changes.IDistributedCache for storing serialized data across multiple servers.IDynamicCacheService to programmatically manage dynamic cache entries.CacheContext to declare cache dependencies, vary-by keys, and expiration policies.{% cache %} blocks in Liquid provide declarative shape caching.{ "steps": [...] }.sealed modifier.{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.ResponseCompression",
"OrchardCore.DynamicCache"
],
"disable": []
}
]
}
Enable OrchardCore.ResponseCompression to compress HTTP responses for the tenant. The module calls AddResponseCompression(options => options.EnableForHttps = true) with the ASP.NET Core default providers and adds UseResponseCompression() early in the pipeline (Startup.Order = -5); no code is required.
Tune the default providers from a startup class if needed:
public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<BrotliCompressionProviderOptions>(options =>
{
options.Level = System.IO.Compression.CompressionLevel.Fastest;
});
services.Configure<GzipCompressionProviderOptions>(options =>
{
options.Level = System.IO.Compression.CompressionLevel.SmallestSize;
});
}
}
OrchardCore.DynamicCache caches the rendered HTML output of shapes. Each cached shape tracks dependencies so it can be evicted when related content changes. Dependencies use the format contentitemid:{id} or custom signal names. See orchardcore-dynamic-cache for full vary-by contexts, nested cache blocks, programmatic caching, and custom cache context providers.
Use the Dynamic Cache <dynamic-cache> tag helper in Razor views:
<dynamic-cache cache-id="recent-posts"
vary-by="route"
dependencies="contentitemid:@Model.ContentItem.ContentItemId"
expires-after="00:10:00">
@await DisplayAsync(Model.Content)
</dynamic-cache>
The tag helper accepts cache-id, vary-by, dependencies, expires-after, expires-sliding, and expires-on. vary-by and dependencies accept comma- or space-separated values.
In Liquid templates, use the {% cache %} tag for shape-level caching:
{% cache "my-cache-key", vary_by: "query:page", expires_after: "00:10:00" %}
{{ Model.Content | shape_render }}
{% endcache %}
Shapes can declare caching behavior through CacheContext. In a shape display driver, configure cache parameters:
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Environment.Cache;
public sealed class RecentPostsDisplayDriver : DisplayDriver<RecentPostsViewModel>
{
public override IDisplayResult Display(RecentPostsViewModel model, BuildDisplayContext context)
{
return View("RecentPosts", model)
.Location("Detail", "Content:5")
.Cache("recentposts", cache => cache
.AddTag("contenttype:BlogPost")
.AddContext("user")
.WithExpiryAfter(TimeSpan.FromMinutes(15))
);
}
}
Common CacheContext methods:
AddContext(string) - Vary by the named context (e.g., "user", "route").AddTag(string) - Associate tags used for invalidation.WithExpiryOn(DateTimeOffset) - Set a fixed expiration instant.WithExpiryAfter(TimeSpan) - Set absolute expiration.WithExpirySliding(TimeSpan) - Set sliding expiration.Use ISignal.SignalTokenAsync to invalidate consumers that registered ISignal.GetToken for the same key. Dynamic Cache entries use CacheContext.AddTag and are invalidated through ITagCache.RemoveTagAsync.
using OrchardCore.Environment.Cache;
public sealed class ProductService
{
private readonly ISignal _signal;
private readonly ITagCache _tagCache;
public ProductService(ISignal signal, ITagCache tagCache)
{
_signal = signal;
_tagCache = tagCache;
}
public async Task InvalidateProductCacheAsync()
{
await _signal.SignalTokenAsync("productcatalog");
await _tagCache.RemoveTagAsync("productcatalog");
}
}
Use the same "productcatalog" key when obtaining the change token. The tag removal invalidates Dynamic Cache entries that called AddTag("productcatalog").
IDistributedCache stores serialized data in a shared cache backend (memory, SQL Server, or Redis). Inject and use it directly:
using Microsoft.Extensions.Caching.Distributed;
public sealed class CatalogCacheService
{
private readonly IDistributedCache _distributedCache;
public CatalogCacheService(IDistributedCache distributedCache)
{
_distributedCache = distributedCache;
}
public async Task<string?> GetCachedCatalogAsync(string key)
{
return await _distributedCache.GetStringAsync(key);
}
public async Task SetCachedCatalogAsync(string key, string value)
{
var options = new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30),
SlidingExpiration = TimeSpan.FromMinutes(10),
};
await _distributedCache.SetStringAsync(key, value, options);
}
public async Task RemoveCachedCatalogAsync(string key)
{
await _distributedCache.RemoveAsync(key);
}
}
IDynamicCacheService provides programmatic access to the dynamic cache for storing and evicting pre-rendered HTML:
using OrchardCore.DynamicCache;
public sealed class WidgetCacheManager
{
private readonly IDynamicCacheService _dynamicCacheService;
private readonly ITagCache _tagCache;
public WidgetCacheManager(
IDynamicCacheService dynamicCacheService,
ITagCache tagCache)
{
_dynamicCacheService = dynamicCacheService;
_tagCache = tagCache;
}
public async Task<string?> GetCachedWidgetAsync(CacheContext context)
{
return await _dynamicCacheService.GetCachedValueAsync(context);
}
public async Task SetCachedWidgetAsync(CacheContext context, string htmlContent)
{
context.AddTag("widget-sidebar");
await _dynamicCacheService.SetCachedValueAsync(context, htmlContent);
}
public async Task InvalidateWidgetAsync()
{
await _tagCache.RemoveTagAsync("widget-sidebar");
}
}
Enable the OrchardCore.Redis and OrchardCore.Redis.Cache features (package OrchardCore.Redis, installed in the web project when not using the full CMS targets). OrchardCore.Redis.Cache replaces the default in-memory IDistributedCache for the tenant, so dynamic cache entries and every IDistributedCache consumer are shared across instances. Add OrchardCore.Redis.Bus to make ISignal distributed.
{
"OrchardCore": {
"Redis": {
"Configuration": "localhost:6379,abortConnect=false,connectTimeout=5000",
"InstancePrefix": "MyApp:"
}
}
}
Environment variable form: OrchardCore__Redis__Configuration. The former OrchardCore_Redis section name still works but is deprecated. See orchardcore-redis.
Configure response cache profiles to set Cache-Control headers for HTTP responses:
public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<MvcOptions>(options =>
{
options.CacheProfiles.Add("Default", new CacheProfile
{
Duration = 300,
Location = ResponseCacheLocation.Any,
VaryByHeader = "Accept-Encoding",
});
options.CacheProfiles.Add("NoCache", new CacheProfile
{
Duration = 0,
Location = ResponseCacheLocation.None,
NoStore = true,
});
});
}
}
[ResponseCache] only emits Cache-Control headers. Server-side response caching additionally needs services.AddResponseCaching() and app.UseResponseCaching(); never cache personalized or authenticated responses that way.
Apply a cache profile to a controller or action:
[ResponseCache(CacheProfileName = "Default")]
public sealed class CatalogController : Controller
{
public IActionResult Index()
{
return View();
}
[ResponseCache(CacheProfileName = "NoCache")]
public IActionResult Checkout()
{
return View();
}
}
Combine IDistributedCache with content queries to avoid repeated database calls:
using System.Text.Json;
using Microsoft.Extensions.Caching.Distributed;
using OrchardCore.ContentManagement;
public sealed class CachedArticleService
{
private readonly IContentManager _contentManager;
private readonly IDistributedCache _distributedCache;
public CachedArticleService(
IContentManager contentManager,
IDistributedCache distributedCache)
{
_contentManager = contentManager;
_distributedCache = distributedCache;
}
public async Task<ContentItem?> GetPublishedArticleAsync(string contentItemId)
{
var cacheKey = $"published-article:{contentItemId}";
var cached = await _distributedCache.GetStringAsync(cacheKey);
if (cached is not null)
{
// JConvert uses Orchard Core's JSON options, required for ContentItem.
return JConvert.DeserializeObject<ContentItem>(cached);
}
var article = await _contentManager.GetAsync(
contentItemId,
VersionOptions.Published);
if (article is null)
{
return null;
}
await _distributedCache.SetStringAsync(
cacheKey,
JConvert.SerializeObject(article),
new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10),
});
return article;
}
// Call from a content handler (PublishedAsync, UnpublishedAsync, RemovedAsync).
public Task InvalidateArticleAsync(string contentItemId)
=> _distributedCache.RemoveAsync($"published-article:{contentItemId}");
}
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/orchardcore:orchardcore-cachingfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job