diff --git a/docs/framework/performance/caching-in-net-framework-applications.md b/docs/framework/performance/caching-in-net-framework-applications.md index f7607519e1d1e..581c85d9bbce5 100644 --- a/docs/framework/performance/caching-in-net-framework-applications.md +++ b/docs/framework/performance/caching-in-net-framework-applications.md @@ -52,7 +52,12 @@ Caching enables you to store data in memory for rapid access. When the data is a ### Output Caching - To manually cache application data, you can use the class in ASP.NET. ASP.NET also supports output caching, which stores the generated output of pages, controls, and HTTP responses in memory. You can configure output caching declaratively in an ASP.NET Web page or by using settings in the Web.config file. For more information, see [outputCache Element for caching (ASP.NET Settings Schema)](/previous-versions/dotnet/netframework-4.0/ms228124(v=vs.100)). + To manually cache application data, you can use the class in ASP.NET. ASP.NET also supports output caching, which stores the generated output of pages, controls, and HTTP responses in memory. When a later request matches a cached response, ASP.NET serves the stored output instead of regenerating it. You can configure output caching declaratively in an ASP.NET Web page or by using settings in the Web.config file. For more information, see [outputCache Element for caching (ASP.NET Settings Schema)](/previous-versions/dotnet/netframework-4.0/ms228124(v=vs.100)). + + A single resource often has more than one representation. For example, a product page varies by product identifier, an agenda view varies by date, and localized content varies by language or culture. `VaryBy` settings—such as `VaryByParam`, `VaryByHeader`, `VaryByCustom`, and `VaryByContentEncoding`—let output caching select and cache these alternate representations based on request characteristics. Output caching then serves the representation that matches each request. + +> [!IMPORTANT] +> Output caching is a performance optimization feature. `VaryBy` settings are intended to cache alternate representations of a resource based on request characteristics. Don't rely on cache variation to provide isolation between classes of content, including personalized, tenant-specific, authorization-dependent, or otherwise sensitive responses. Enforce any required isolation independently of cache configuration. ASP.NET lets you extend output caching by creating custom output-cache providers. By using custom providers, you can store cached content using other storage devices such as disks, cloud storage, and distributed cache engines. To create a custom output cache provider, you create a class that derives from the class and configure the application to use the custom output cache provider. diff --git a/docs/framework/wcf/feature-details/caching-support-for-wcf-web-http-services.md b/docs/framework/wcf/feature-details/caching-support-for-wcf-web-http-services.md index fc564ad83d956..ff7db0c8e3088 100644 --- a/docs/framework/wcf/feature-details/caching-support-for-wcf-web-http-services.md +++ b/docs/framework/wcf/feature-details/caching-support-for-wcf-web-http-services.md @@ -56,6 +56,9 @@ Also turn on ASP.NET compatibility mode in the Web.config file as shown in the f This is the same configuration element that's available to ASP.NET applications. For more information about ASP.NET cache profiles, see . For Web HTTP services, the most important attributes in the cache profile are: `cacheDuration` and `varyByParam`. Both of these attributes are required. `cacheDuration` sets the amount of time a response should be cached in seconds. `varyByParam` allows you to specify a query string parameter that is used to cache responses. All requests made with different query string parameter values are cached separately. For example, once an initial request is made to `http://MyServer/MyHttpService/MyOperation?param=10`, all subsequent requests made with the same URI would be returned the cached response (so long as the cache duration has not elapsed). Responses for a similar request that is the same but has a different value for the parameter query string parameter are cached separately. If you do not want this separate caching behavior, set `varyByParam` to "none". +> [!IMPORTANT] +> Output caching is a performance optimization feature. The `varyByParam` setting caches alternate representations of a response based on request characteristics. Don't rely on cache variation to isolate classes of content, such as personalized, tenant-specific, authorization-dependent, or otherwise sensitive responses. Enforce any required isolation independently of cache configuration. + ## SQL Cache Dependency Web HTTP service responses can also be cached with a SQL cache dependency. If your WCF Web HTTP service depends on data stored in a SQL database, you might want to cache the service's response and invalidate the cached response when data in the SQL database table changes. This behavior is configured completely within the Web.config file. First, define a connection string in the `` element. diff --git a/docs/framework/wcf/samples/aspnet-caching-integration.md b/docs/framework/wcf/samples/aspnet-caching-integration.md index fcc96c4ea1ffa..174df86f0f9f7 100644 --- a/docs/framework/wcf/samples/aspnet-caching-integration.md +++ b/docs/framework/wcf/samples/aspnet-caching-integration.md @@ -16,10 +16,13 @@ Integration with the ASP.NET Output Cache. The sample uses the to utilize ASP.NET output caching with the Windows Communication Foundation (WCF) service. The is applied to service operations, and provides the name of a cache profile in a configuration file that should be applied to responses from the given operation. -In the Service.cs file of the sample Service project, both the `GetCustomer` and `GetCustomers` operations are marked with the , which provides the cache profile name "CacheFor60Seconds". In the Web.config file of the Service project, the cache profile "CacheFor60Seconds" is provided under the `` element of ``. For this cache profile, the value of the `duration` attribute is "60", so responses associated with this profile are cached in the ASP.NET output cache for 60 seconds. Also, for this cache profile, the `varmByParam` attribute is set to "format" so requests with different values for the `format` query string parameter have their responses cached separately. Lastly, the cache profile's `varyByHeader` attribute is set to "Accept", so requests with different Accept header values have their responses cached separately. +In the Service.cs file of the sample Service project, both the `GetCustomer` and `GetCustomers` operations are marked with the , which provides the cache profile name "CacheFor60Seconds". In the Web.config file of the Service project, the cache profile "CacheFor60Seconds" is provided under the `` element of ``. For this cache profile, the value of the `duration` attribute is "60", so responses associated with this profile are cached in the ASP.NET output cache for 60 seconds. Also, for this cache profile, the `varyByParam` attribute is set to "format" so requests with different values for the `format` query string parameter have their responses cached separately. Lastly, the cache profile's `varyByHeader` attribute is set to "Accept", so requests with different Accept header values have their responses cached separately. Program.cs in the Client project demonstrates how such a client can be authored using . Note that this is just one way to access a WCF service. It is also possible to access the service using other .NET Framework classes like the WCF channel factory and . Other samples in the SDK (such as the [Basic HTTP Service](basic-http-service.md) sample) illustrate how to use these classes to communicate with a WCF service. +> [!IMPORTANT] +> Output caching is a performance optimization feature. The `varyByParam` and `varyByHeader` settings cache alternate representations of a response based on request characteristics. Don't rely on cache variation to isolate classes of content, such as personalized, tenant-specific, authorization-dependent, or otherwise sensitive responses. Enforce any required isolation independently of cache configuration. + ## To run the sample The sample consists of three projects: