From 3353a3ada519b414dc4158eefce2a153f6c5956c Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Thu, 9 Dec 2021 17:14:09 -1000 Subject: [PATCH] Prep monikers for V6 (#24255) --- aspnetcore/fundamentals/index.md | 3 +-- aspnetcore/performance/caching/middleware.md | 21 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/aspnetcore/fundamentals/index.md b/aspnetcore/fundamentals/index.md index 7cc3dcd12c..eb4c245432 100644 --- a/aspnetcore/fundamentals/index.md +++ b/aspnetcore/fundamentals/index.md @@ -15,7 +15,7 @@ uid: fundamentals/index This article provides an overview of key topics for understanding how to develop ASP.NET Core apps. -## The Startup class +## Program.cs The `Startup` class is where: @@ -26,7 +26,6 @@ Here's a sample `Startup` class: [!code-csharp[](index/samples_snapshot/3.x/Startup.cs?highlight=3,12)] -For more information, see . ## Dependency injection (services) diff --git a/aspnetcore/performance/caching/middleware.md b/aspnetcore/performance/caching/middleware.md index 7490c6b971..255a478564 100644 --- a/aspnetcore/performance/caching/middleware.md +++ b/aspnetcore/performance/caching/middleware.md @@ -2,10 +2,10 @@ title: Response Caching Middleware in ASP.NET Core author: rick-anderson description: Learn how to configure and use Response Caching Middleware in ASP.NET Core. -monikerRange: '>= aspnetcore-2.1' +monikerRange: '>= aspnetcore-3.1' ms.author: riande ms.custom: mvc -ms.date: 02/07/2020 +ms.date: 12/07/2021 no-loc: [Home, Privacy, Kestrel, appsettings.json, "ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR] uid: performance/caching/middleware --- @@ -13,7 +13,7 @@ uid: performance/caching/middleware By [John Luo](https://github.com/JunTaoLuo) -::: moniker range=">= aspnetcore-3.0" +::: moniker range=">= aspnetcore-6.0" This article explains how to configure Response Caching Middleware in an ASP.NET Core app. The middleware determines when responses are cacheable, stores responses, and serves responses from cache. For an introduction to HTTP caching and the [`[ResponseCache]`](xref:Microsoft.AspNetCore.Mvc.ResponseCacheAttribute) attribute, see [Response Caching](xref:performance/caching/response). @@ -160,7 +160,7 @@ When testing and troubleshooting caching behavior, a browser may set request hea ::: moniker-end -::: moniker range="< aspnetcore-3.0" +::: moniker range="< aspnetcore-6.0" This article explains how to configure Response Caching Middleware in an ASP.NET Core app. The middleware determines when responses are cacheable, stores responses, and serves responses from cache. For an introduction to HTTP caching and the [`[ResponseCache]`](xref:Microsoft.AspNetCore.Mvc.ResponseCacheAttribute) attribute, see [Response Caching](xref:performance/caching/response). @@ -168,22 +168,25 @@ This article explains how to configure Response Caching Middleware in an ASP.NET ## Configuration -Use the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapackage-app) or add a package reference to the [Microsoft.AspNetCore.ResponseCaching](https://www.nuget.org/packages/Microsoft.AspNetCore.ResponseCaching/) package. +Response Caching Middleware is implicitly available for ASP.NET Core apps via the shared framework. In `Startup.ConfigureServices`, add the Response Caching Middleware to the service collection: -[!code-csharp[](middleware/samples/2.x/ResponseCachingMiddleware/Startup.cs?name=snippet1&highlight=3)] +[!code-csharp[](middleware/samples/3.x/ResponseCachingMiddleware/Startup.cs?name=snippet1&highlight=3)] Configure the app to use the middleware with the extension method, which adds the middleware to the request processing pipeline in `Startup.Configure`: -[!code-csharp[](middleware/samples/2.x/ResponseCachingMiddleware/Startup.cs?name=snippet2&highlight=14)] +[!code-csharp[](middleware/samples/3.x/ResponseCachingMiddleware/Startup.cs?name=snippet2&highlight=17)] + +> [!WARNING] +> must be called before when using [CORS middleware](xref:security/cors). The sample app adds headers to control caching on subsequent requests: * [Cache-Control](https://tools.ietf.org/html/rfc7234#section-5.2): Caches cacheable responses for up to 10 seconds. * [Vary](https://tools.ietf.org/html/rfc7231#section-7.1.4): Configures the middleware to serve a cached response only if the [Accept-Encoding](https://tools.ietf.org/html/rfc7231#section-5.3.4) header of subsequent requests matches that of the original request. -[!code-csharp[](middleware/samples_snippets/2.x/AddHeaders.cs)] +[!code-csharp[](middleware/samples_snippets/3.x/AddHeaders.cs)] The preceding headers are not written to the response and are overridden when a controller, action, or Razor Page: @@ -302,4 +305,4 @@ When testing and troubleshooting caching behavior, a browser may set request hea * * -::: moniker-end \ No newline at end of file +::: moniker-end