---
title: "What is OutputCache Attribute in ASP.NET MVC ?"  
description: "What is OutputCache Attribute in ASP.NET MVC ?"  
author: "Rahul Roi"  
published: 2020-10-28  
updated: 2020-10-28  
canonical: https://www.mindstick.com/forum/156059/what-is-outputcache-attribute-in-asp-dot-net-mvc  
category: "asp.net mvc"  
tags: ["c#", "asp.net mvc", "mvc", "validation"]  
reading_time: 1 minute  

---

# What is OutputCache Attribute in ASP.NET MVC ?

OutputCache [Attribute](https://www.mindstick.com/blog/221/attributes-reflection) in [ASP.NET MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc)

## Replies

### Reply by Shrikant Mishra

Into [ASP.NET](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [MVC](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc), the OutputCaching basically allows you to store the output of a particular controller in the memory. So, any future request coming for the same action in that controller will be returned from the cached result. This way, the same content does not need to be generated each and every time the same controller action is invoked.

- VaryByParam
- VaryByHeader

```
public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
    services.AddOutputCaching();
    services.AddMvc();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    app.UseOutputCaching();
    app.UseMvcWithDefaultRoute();
    }
}
```


---

Original Source: https://www.mindstick.com/forum/156059/what-is-outputcache-attribute-in-asp-dot-net-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
