Output caching API changes

Some APIs in the Microsoft.AspNetCore.OutputCaching namespace have changed to better represent their intent.

The following APIs were removed:

  • OutputCachePolicyBuilder.#ctor
  • OutputCachePolicyBuilder.Clear

The following APIs were renamed:

Previous name New name
AllowLocking(System.Boolean) SetLocking(Boolean)
VaryByRouteValue(System.String[]) SetVaryByRouteValue(String[])
VaryByQuery(System.String[]) SetVaryByQuery(String[])
VaryByHeader(System.String[]) SetVaryByHeader(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 OutputCachePolicyBuilder.SetVaryByQuery(String[]), 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[])