Configures dynamic caching in Orchard Core: shape-level caching, Razor/Liquid cache blocks, cache contexts, dependencies, invalidation with ITagCache/ISignal, and custom ICacheContextProvider.
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.
None: SKILL.md is the whole skill.
You are an Orchard Core expert. Generate code and configuration for dynamic caching including shape-level caching, tag helpers, Liquid cache blocks, cache contexts, dependencies, variations, invalidation, and performance optimization. For response compression, distributed cache providers, and cache-control/response headers, see orchardcore-caching.
OrchardCore.DynamicCache for shape-level output caching with dependency tracking.IDynamicCache, backed by IDistributedCache (defaults to IMemoryCache).<dynamic-cache> tag helper defaults to a 30-second sliding window when no expiration is set. Programmatic and Liquid cache entries use the dynamic-cache service default.contentitemid:{ContentItemId} and alias:{Alias} dependencies to auto-invalidate when content changes.ITagCache.RemoveTagAsync().user is more specialized than user.roles, so if both are specified, only user is used.<dynamic-cache> tag helper in Razor (not <cache>, which is the ASP.NET Core built-in).{% cache %} blocks in Liquid for declarative caching.cache_dependency, cache_expires_after, etc.) to alter cache policies from within nested content.{ "steps": [...] }.sealed modifier.{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.DynamicCache"
],
"disable": []
}
]
}
| Dependency | Description |
|---|---|
contentitemid:{ContentItemId} | Invalidated when the content item is Published, Unpublished, or Removed |
alias:{Alias} | Invalidated when the content item with the specified alias is Published, Unpublished, or Removed |
Create custom dependencies by calling ITagCache.RemoveTagAsync() in response to events.
| Context | Description |
|---|---|
features | The list of enabled features |
features:{featureName} | A specific feature name |
query | All query string values |
query:{queryName} | A specific query string parameter |
user | The current user |
user.roles | The roles of the current user |
route | The current request path |
Contexts are hierarchical. For example, user is more specific than user.roles. If both are declared, only user is used.
| Razor Attribute | Description | Required |
|---|---|---|
cache-id | The identifier of the cached section | Yes |
vary-by | Space/comma-separated cache contexts | No |
dependencies | Space/comma-separated invalidation tags | No |
expires-on | Fixed DateTimeOffset expiration | No |
expires-after | Relative expiration | No |
expires-sliding | Sliding expiration (30 seconds when no expiration is set) | No |
@addTagHelper *, OrchardCore.DynamicCache
<dynamic-cache cache-id="recent-posts" vary-by="user.roles" dependencies="alias:recent-posts" expires-after="00:10:00">
@foreach (var post in Model.Posts)
{
<cache-dependency dependency="contentitemid:@post.ContentItemId" />
<a display-for="@post">@post.DisplayText</a>
}
</dynamic-cache>
<cache-dependency dependency="..." /> adds a dependency to the enclosing cache scope while it renders, like the Liquid cache_dependency tag.
<shape>, <menu>, <contentitem>, and other shape tag helpers accept cache-id, cache-context, cache-tag, cache-fixed-duration, and cache-sliding-duration:
<menu alias="alias:main-menu" cache-id="main-menu" cache-fixed-duration="00:05:00" cache-tag="alias:main-menu" cache-context="user.roles" />
Liquid shape and contentitem tags cache a shape with cache_id, cache_context, cache_dependency, cache_tag, cache_fixed_duration, and cache_sliding_duration. shape_cache sets the same arguments on an existing shape ({% shape_cache my_shape cache_id: "my-shape", cache_fixed_duration: "00:05:00" %}):
{% shape "menu", alias: "alias:main-menu", cache_id: "main-menu", cache_fixed_duration: "00:05:00", cache_tag: "alias:main-menu" %}
Cache a content item shape:
{% contentitem alias: "alias:main-menu", cache_id: "main-menu", cache_fixed_duration: "00:05:00", cache_tag: "alias:main-menu" %}
Use ShapeMetadata.Cache() to mark a shape as cached in a display driver:
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
public sealed class RecentPostsDisplayDriver : DisplayDriver<RecentPostsWidget>
{
public override IDisplayResult Display(RecentPostsWidget model, BuildDisplayContext context)
{
return View("RecentPosts", model)
.Location("Detail", "Content:5")
.Cache("recentposts", cache => cache
.AddTag("contenttype:BlogPost")
.AddContext("user")
.WithExpiryAfter(TimeSpan.FromMinutes(15))
);
}
}
| Method | Description |
|---|---|
WithExpiryOn(DateTimeOffset) | Cache until a fixed point in time |
WithExpiryAfter(TimeSpan) | Cache for a fixed duration |
WithExpirySliding(TimeSpan) | Cache with a sliding window |
AddContext(params string[]) | Vary cached content by the specified context values |
RemoveContext(string) | Remove a context |
AddTag(params string[]) | Add invalidation tags |
RemoveTag(string) | Remove a tag |
Use {% cache %} blocks in Liquid templates for declarative caching. Blocks can be nested:
| Argument | Description | Required |
|---|---|---|
id (first positional) | The cache block identifier | Yes |
vary_by | Space/comma-separated context values, or a custom value such as a content item id | No |
dependencies | Space/comma-separated dependency values | No |
expires_after | Fixed duration (e.g., "00:05:00") | No |
expires_sliding | Sliding duration (e.g., "00:05:00") | No |
The block reads vary_by; the contexts name shown in some older docs is not recognized.
{% cache "my-cache-block" %}
<p>This content is cached.</p>
{% endcache %}
{% cache "blog-post-summary", vary_by: Model.ContentItem.ContentItemId %}
<h2>{{ Model.ContentItem | display_text }}</h2>
<p>{{ Model.ContentItem.Content.HtmlBodyPart.Html | sanitize_html | raw }}</p>
{% endcache %}
{% cache "a" %}
A {{ "now" | date: "%T" }} (No Duration) <br />
{% cache "a1", dependencies: "a1", vary_by: "user", expires_after: "0:5:0" %}
A1 {{ "now" | date: "%T" }} (5 Minutes) <br />
{% endcache %}
{% cache "a2", dependencies: "a2", expires_after: "0:0:1" %}
A2 {{ "now" | date: "%T" }} (1 Second) <br />
{% cache "a2a", dependencies: "a2a", vary_by: "route", expires_sliding: "0:0:5" %}
A2A {{ "now" | date: "%T" }} (5 Seconds) <br />
{% endcache %}
{% endcache %}
{% endcache %}
Use these Liquid tags to alter the current cache scope from inside a cache block. These tags are safe to use even if you are not inside a cache block:
| Tag | Description | Example |
|---|---|---|
cache_dependency | Add a dependency to the current scope | {% cache_dependency "alias:my-alias" %} |
cache_expires_on | Set a fixed expiration date/time | {% cache_expires_on someDate %} |
cache_expires_after | Set a relative expiration duration | {% cache_expires_after "01:00:00" %} |
cache_expires_sliding | Set a sliding window expiration | {% cache_expires_sliding "00:01:00" %} |
{% cache "recent-blog-posts" %}
{% assign recentBlogPosts = Queries.RecentBlogPosts | query %}
{% for item in recentBlogPosts %}
{{ item | display_text }}
{% assign cacheDependency = "contentitemid:" | append: item.ContentItemId %}
{% cache_dependency cacheDependency %}
{% endfor %}
{% endcache %}
Use ISignal.SignalTokenAsync for consumers that registered ISignal.GetToken for the same key. To invalidate Dynamic Cache entries tagged with AddTag, use 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");
}
}
The signal API remains useful for signal-token consumers. The tag removal invalidates Dynamic Cache entries that called AddTag("productcatalog").
Implement ICacheContextProvider to create custom context values for cache variation:
using OrchardCore.Environment.Cache;
public sealed class TenantCacheContextProvider : ICacheContextProvider
{
private readonly IHttpContextAccessor _httpContextAccessor;
public TenantCacheContextProvider(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public Task PopulateContextEntriesAsync(IEnumerable<string> contexts, List<CacheContextEntry> entries)
{
if (contexts.Any(ctx => string.Equals(ctx, "tenant", StringComparison.OrdinalIgnoreCase)))
{
var tenantName = _httpContextAccessor.HttpContext?.Request.Host.Value ?? "default";
entries.Add(new CacheContextEntry("tenant", tenantName));
}
return Task.CompletedTask;
}
}
{
"OrchardCore": {
"DynamicCache": {
"FailoverRetryLatency": "00:00:30"
}
}
}
FailoverRetryLatency is how long the dynamic cache stops using the distributed cache after a read or write failure (for example a Redis outage) before trying again. The former OrchardCore_DynamicCache section name still works but is deprecated.
Dynamic Cache has four modes, set by Cache mode on the Cache tab (Dynamic cache card) of Settings > General:
Production ASP.NET Core environment only.What SKILL.md sets; muted values are Claude Code's defaults
/orchardcore:orchardcore-dynamic-cachefrom 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