Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Imagine, for example, that your ASP.NET MVC application displays a list of datab

If, on the other hand, you take advantage of the output cache then you can avoid executing a database query every time any user invokes the same controller action. The view can be retrieved from the cache instead of being regenerated from the controller action. Caching enables you to avoid performing redundant work on the server.

> [!IMPORTANT]
> Output caching is a performance optimization. The `VaryBy` settings (such as `VaryByParam`, `VaryByHeader`, and `VaryByCustom`) exist to cache alternate *representations* of a resource based on request characteristics — for example, a product page that varies by product ID, an agenda that varies by date, or content rendered in a different language. They are not a way to isolate audiences or classes of content. Don't rely on cache variation to separate personalized, tenant-specific, authorization-dependent, or otherwise sensitive responses; enforce any required isolation in your application, independently of cache configuration.

## Enabling Output Caching

You enable output caching by adding an [OutputCache] attribute to either an individual controller action or an entire controller class. For example, the controller in Listing 1 exposes an action named Index(). The output of the Index() action is cached for 10 seconds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Imagine, for example, that your ASP.NET MVC application displays a list of datab

If, on the other hand, you take advantage of the output cache then you can avoid executing a database query every time any user invokes the same controller action. The view can be retrieved from the cache instead of being regenerated from the controller action. Caching enables you to avoid performing redundant work on the server.

> [!IMPORTANT]
> Output caching is a performance optimization. The `VaryBy` settings (such as `VaryByParam`, `VaryByHeader`, and `VaryByCustom`) exist to cache alternate *representations* of a resource based on request characteristics — for example, a product page that varies by product ID, an agenda that varies by date, or content rendered in a different language. They are not a way to isolate audiences or classes of content. Don't rely on cache variation to separate personalized, tenant-specific, authorization-dependent, or otherwise sensitive responses; enforce any required isolation in your application, independently of cache configuration.

#### Enabling Output Caching

You enable output caching by adding an <OutputCache> attribute to either an individual controller action or an entire controller class. For example, the controller in Listing 1 exposes an action named Index(). The output of the Index() action is cached for 10 seconds.
Expand Down
3 changes: 3 additions & 0 deletions aspnet/web-forms/overview/moving-to-aspnet-20/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ by [Microsoft](https://github.com/microsoft)

An understanding of caching is important for a well-performing ASP.NET application. ASP.NET 1.x offered three different options for caching; output caching, fragment caching, and the cache API. ASP.NET 2.0 offers all three of these methods, but it adds some significant additional features. There are several new cache dependencies and developers now have the option to create custom cache dependencies as well. The configuration of caching has also been improved significantly in ASP.NET 2.0.

> [!IMPORTANT]
> Output caching is a performance optimization. The `@ OutputCache` directive and its `VaryBy` settings (such as `VaryByParam`, `VaryByHeader`, and `VaryByCustom`) exist to cache alternate *representations* of a page based on request characteristics — for example, a product page that varies by product ID, an agenda that varies by date, or content rendered in a different language. They are not a way to isolate audiences or classes of content. Don't rely on cache variation to separate personalized, tenant-specific, authorization-dependent, or otherwise sensitive responses; enforce any required isolation in your application, independently of cache configuration.

## New Features

## Cache Profiles
Expand Down
3 changes: 3 additions & 0 deletions aspnet/whitepapers/aspnet4/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ Specifying a different output cache provider for an HTTP request requires a litt

With the addition of output-cache provider extensibility to ASP.NET 4, you can now pursue more aggressive and more intelligent output-caching strategies for your Web sites. For example, it is now possible to cache the "Top 10" pages of a site in memory, while caching pages that get lower traffic on disk. Alternatively, you can cache every vary-by combination for a rendered page, but use a distributed cache so that the memory consumption is offloaded from front-end Web servers.

> [!IMPORTANT]
> Output caching, including custom output-cache providers and any `VaryBy` combinations, is a performance optimization that stores alternate *representations* of a resource. It is not a way to isolate audiences or classes of content. Don't rely on cache variation or provider selection to separate personalized, tenant-specific, authorization-dependent, or otherwise sensitive responses; enforce any required isolation in your application, independently of cache configuration.

<a id="0.2__Toc224729020"></a><a id="0.2__Toc253429241"></a><a id="0.2__Toc243304615"></a>

### Auto-Start Web Applications
Expand Down