Back to Aspnetcore

Breaking change: Output caching API changes

aspnetcore/breaking-changes/7/output-caching-renames.md

latest3.2 KB
Original Source

Output caching API changes

Some APIs in the xref:Microsoft.AspNetCore.OutputCaching?displayProperty=fullName namespace have changed to better represent their intent.

The following APIs were removed:

  • OutputCachePolicyBuilder.#ctor
  • OutputCachePolicyBuilder.Clear

The following APIs were renamed:

Previous nameNew name
AllowLocking(System.Boolean)xref:Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.SetLocking(System.Boolean)
VaryByRouteValue(System.String[])xref:Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.SetVaryByRouteValue(System.String[])
VaryByQuery(System.String[])xref:Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.SetVaryByQuery(System.String[])
VaryByHeader(System.String[])xref:Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.SetVaryByHeader(System.String[])

The following APIs were added:

Version introduced

ASP.NET Core 7.0 RC 2

Previous behavior

OutputCachePolicyBuilder.VaryByQuery(System.String[]) was additive: every call added more query string keys.

New behavior

The OutputCachePolicyBuilder.VaryByQuery(System.String[]) method is now named xref:Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.SetVaryByQuery(System.String[])?displayProperty=nameWithType, and each call replaces existing query string keys.

For other changes, see the first section of this article.

Type of breaking change

This change affects source compatibility and binary compatibility.

Reason for change

This change was made to improve the consistency of method names and to remove ambiguity in their behavior.

Recompile any projects built with an earlier SDK. If you referenced any of these method names directly, update the source to reflect the new names.

Affected APIs

  • Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.#ctor
  • Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.Clear
  • Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.AllowLocking(System.Boolean)
  • Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.VaryByRouteValue(System.String[])
  • Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.VaryByQuery(System.String[])
  • Microsoft.AspNetCore.OutputCaching.OutputCachePolicyBuilder.VaryByHeader(System.String[])