Using Output Caching
Learn about implementing the output caching in ASP.NET Core MVC, providing examples of caching endpoints and MVC views with step-by-step instructions.
We'll cover the following
In some ways, output caching is similar to response caching. Output caching can store dynamically generated responses on the server so that they do not have to be regenerated again for another request. This can improve performance.
Output caching endpoints
Let’s see it in action with a really simple example of applying output caching to some endpoints to make sure it is working properly:
Step 1: In the Northwind.Mvc
project, in Program.cs
, add statements after the call to AddNorthwindContext
to add the output cache middleware and override the default expiration timespan to make it only 10 seconds, as shown highlighted in the following code:
Get hands-on with 1400+ tech skills courses.