You have a server-rendered Blazor page where one component does expensive work. The rest of the page is personal, changes often, or simply doesn’t belong in an output cache.

Caching the whole response is too much. Running the expensive component on every request is too little.

.NET 11 adds CacheView, which caches the rendered output of one component subtree during static server-side rendering.

Try It

Create a .NET 11 Blazor Web App with global static rendering:

Terminal window
dotnet new blazor -n CacheViewDemo -f net11.0 --interactivity None
cd CacheViewDemo

Add Components/Pages/Products.razor:

@page "/products"
<PageTitle>Products</PageTitle>
<h1>Products</h1>
<p>This timestamp changes with every request: @DateTimeOffset.Now</p>
<CacheView VaryByQuery="category"
ExpiresAfter="TimeSpan.FromSeconds(30)">
<ProductList Category="@Category" />
</CacheView>
@code {
[SupplyParameterFromQuery]
public string Category { get; set; } = "keyboards";
}

Add Components/ProductList.razor:

<div class="alert alert-secondary">
<strong>Rendered at:</strong> @renderedAt
<br />
<strong>Category:</strong> @Category
</div>
@code {
[Parameter, EditorRequired]
public string Category { get; set; } = "";
private readonly DateTimeOffset renderedAt = DateTimeOffset.Now;
}

Run the app:

Terminal window
dotnet run

Open /products?category=keyboards and refresh the page. The timestamp outside CacheView changes. The timestamp inside stays put for 30 seconds.

Change the category:

/products?category=monitors

VaryByQuery="category" creates a different cache entry for that query value.

What Happens on a Cache Hit

Blazor replays the cached markup. It doesn’t instantiate ProductList, and it doesn’t run that component’s lifecycle.

That is the real win when the child component performs an expensive database query or builds a large chunk of mostly static HTML.

When Not to Use It

Don’t cache user-specific, permission-sensitive, or interactive output unless your cache key varies by everything that makes the result different.

CacheView is for static SSR. If the child needs interactive state or must run on every request, caching its markup is the wrong tool.

Key Takeaway

CacheView lets you cache one expensive region of a static Blazor page without caching the entire response. Vary the entry by the inputs that matter, and be honest about whether the output is safe to share.