Skip to content

Commit 3353a3a

Browse files
Prep monikers for V6 (#24255)
1 parent 7e83f8d commit 3353a3a

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

aspnetcore/fundamentals/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ uid: fundamentals/index
1515

1616
This article provides an overview of key topics for understanding how to develop ASP.NET Core apps.
1717

18-
## The Startup class
18+
## Program.cs
1919

2020
The `Startup` class is where:
2121

@@ -26,7 +26,6 @@ Here's a sample `Startup` class:
2626

2727
[!code-csharp[](index/samples_snapshot/3.x/Startup.cs?highlight=3,12)]
2828

29-
For more information, see <xref:fundamentals/startup>.
3029

3130
## Dependency injection (services)
3231

aspnetcore/performance/caching/middleware.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
title: Response Caching Middleware in ASP.NET Core
33
author: rick-anderson
44
description: Learn how to configure and use Response Caching Middleware in ASP.NET Core.
5-
monikerRange: '>= aspnetcore-2.1'
5+
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 02/07/2020
8+
ms.date: 12/07/2021
99
no-loc: [Home, Privacy, Kestrel, appsettings.json, "ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: performance/caching/middleware
1111
---
1212
# Response Caching Middleware in ASP.NET Core
1313

1414
By [John Luo](https://github.com/JunTaoLuo)
1515

16-
::: moniker range=">= aspnetcore-3.0"
16+
::: moniker range=">= aspnetcore-6.0"
1717

1818
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).
1919

@@ -160,30 +160,33 @@ When testing and troubleshooting caching behavior, a browser may set request hea
160160

161161
::: moniker-end
162162

163-
::: moniker range="< aspnetcore-3.0"
163+
::: moniker range="< aspnetcore-6.0"
164164

165165
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).
166166

167167
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/performance/caching/middleware/samples) ([how to download](xref:index#how-to-download-a-sample))
168168

169169
## Configuration
170170

171-
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.
171+
Response Caching Middleware is implicitly available for ASP.NET Core apps via the shared framework.
172172

173173
In `Startup.ConfigureServices`, add the Response Caching Middleware to the service collection:
174174

175-
[!code-csharp[](middleware/samples/2.x/ResponseCachingMiddleware/Startup.cs?name=snippet1&highlight=3)]
175+
[!code-csharp[](middleware/samples/3.x/ResponseCachingMiddleware/Startup.cs?name=snippet1&highlight=3)]
176176

177177
Configure the app to use the middleware with the <xref:Microsoft.AspNetCore.Builder.ResponseCachingExtensions.UseResponseCaching*> extension method, which adds the middleware to the request processing pipeline in `Startup.Configure`:
178178

179-
[!code-csharp[](middleware/samples/2.x/ResponseCachingMiddleware/Startup.cs?name=snippet2&highlight=14)]
179+
[!code-csharp[](middleware/samples/3.x/ResponseCachingMiddleware/Startup.cs?name=snippet2&highlight=17)]
180+
181+
> [!WARNING]
182+
> <xref:Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions.UseCors%2A> must be called before <xref:Microsoft.AspNetCore.Builder.ResponseCachingExtensions.UseResponseCaching%2A> when using [CORS middleware](xref:security/cors).
180183
181184
The sample app adds headers to control caching on subsequent requests:
182185

183186
* [Cache-Control](https://tools.ietf.org/html/rfc7234#section-5.2): Caches cacheable responses for up to 10 seconds.
184187
* [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.
185188

186-
[!code-csharp[](middleware/samples_snippets/2.x/AddHeaders.cs)]
189+
[!code-csharp[](middleware/samples_snippets/3.x/AddHeaders.cs)]
187190

188191
The preceding headers are not written to the response and are overridden when a controller, action, or Razor Page:
189192

@@ -302,4 +305,4 @@ When testing and troubleshooting caching behavior, a browser may set request hea
302305
* <xref:mvc/views/tag-helpers/builtin-th/cache-tag-helper>
303306
* <xref:mvc/views/tag-helpers/builtin-th/distributed-cache-tag-helper>
304307

305-
::: moniker-end
308+
::: moniker-end

0 commit comments

Comments
 (0)