Skip to content

Commit 6f648ec

Browse files
committed
refresh content
1 parent c954af6 commit 6f648ec

7 files changed

Lines changed: 374 additions & 329 deletions

File tree

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
The Response caching middleware:
1+
The response caching middleware enables the caching of server responses based on [HTTP Cache-Control headers](https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/Cache-Control).
22

3-
* Enables caching server responses based on [HTTP cache headers](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control). Implements the standard HTTP caching semantics. Caches based on HTTP cache headers like proxies do.
4-
* Is typically not beneficial for UI apps such as Razor Pages because browsers generally set request headers that prevent caching. [Output caching](xref:performance/caching/output), which is available in .NET 7 or later, benefits UI apps. With output caching, configuration decides what should be cached independently of HTTP headers.
5-
* May be beneficial for public GET or HEAD API requests from clients where the [Conditions for caching](xref:performance/caching/middleware#cfc) are met.
3+
* Caching behavior implements standard HTTP caching semantics.
64

7-
To test response caching, use [Fiddler](https://www.telerik.com/fiddler), or another tool that can explicitly set request headers. Setting headers explicitly is preferred for testing caching. For more information, see [Troubleshooting](xref:performance/caching/middleware#troubleshooting).
5+
* Caching is based on HTTP cache headers similar to the method used by proxies.
6+
7+
* This form of caching is useful for public GET or HEAD API requests from clients where the [conditions for caching](xref:performance/caching/middleware#cfc) are satisfied.
8+
9+
* For UI apps like Razor Pages, response caching isn't typically beneficial. Browsers commonly set request headers that prevent caching.
10+
11+
[Output caching](xref:performance/caching/output) (available in .NET 7 and later) is a better approach for UI apps. In this scenario, the configuration determines what to cache independent of HTTP headers.
12+
13+
To test response caching, use [Fiddler](https://www.telerik.com/fiddler) or another tool that can explicitly set request headers. Setting headers explicitly is preferred for testing caching. For more information, see [Response caching middleware > Troubleshooting](xref:performance/caching/middleware#troubleshooting).

aspnetcore/performance/caching/distributed.md

Lines changed: 116 additions & 115 deletions
Large diffs are not rendered by default.

aspnetcore/performance/caching/hybrid/includes/overview.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
The <xref:Microsoft.Extensions.Caching.Hybrid.HybridCache> API bridges some gaps in the <xref:Microsoft.Extensions.Caching.Distributed.IDistributedCache> and <xref:Microsoft.Extensions.Caching.Memory.IMemoryCache> APIs. `HybridCache` is an abstract class with a default implementation that handles most aspects of saving to cache and retrieving from cache.
1+
The <xref:Microsoft.Extensions.Caching.Hybrid.HybridCache> API bridges gaps in the <xref:Microsoft.Extensions.Caching.Distributed.IDistributedCache> and <xref:Microsoft.Extensions.Caching.Memory.IMemoryCache> APIs. `HybridCache` is an abstract class with a default implementation that handles most aspects of saving to cache and retrieving from cache.
22

3-
### Features
3+
### Features of HybridCache
44

5-
`HybridCache` has the following features that the other APIs don't have:
5+
`HybridCache` provides the following features that aren't available with other APIs:
66

77
* A unified API for both in-process and out-of-process caching.
88

@@ -11,13 +11,13 @@ simple API for adding new caching code. If the app has an `IDistributedCache` im
1111

1212
* Stampede protection.
1313

14-
*Cache stampede* happens when a frequently used cache entry is revoked, and too many requests try to repopulate the same cache entry at the same time. `HybridCache` combines concurrent operations, ensuring that all requests for a given response wait for the first request to populate the cache.
14+
*Cache stampede* happens when a frequently used cache entry is revoked, and too many requests try to repopulate the same cache entry at the same time. `HybridCache` combines concurrent operations, which ensures that all requests for a given response wait for the first request to populate the cache.
1515

1616
* Configurable serialization.
1717

18-
Serialization is configured as part of registering the service, with support for type-specific and generalized serializers via the `WithSerializer` and `WithSerializerFactory` methods, chained from the `AddHybridCache` call. By default, the service handles `string` and `byte[]` internally, and uses `System.Text.Json` for everything else. It can be configured for other types of serializers, such as protobuf or XML.
18+
Serialization is configured as part of registering the service, with support for type-specific and generalized serializers via the `WithSerializer` and `WithSerializerFactory` methods, chained from the `AddHybridCache` call. By default, the service handles `string` and `byte[]` types internally, and uses the `System.Text.Json` namespace for everything else. `HybridCache` can be configured for other types of serializers, such as protobuf or XML.
1919

20-
To see the relative simplicity of the `HybridCache` API, compare code that uses it to code that uses `IDistributedCache`. Here's an example of what using `IDistributedCache` looks like:
20+
To see the relative simplicity of the `HybridCache` API, compare code that uses it to code that uses the `IDistributedCache` interface. Here's an example of a configuration with the `IDistributedCache` interface:
2121

2222
```csharp
2323
public class SomeService(IDistributedCache cache)
@@ -52,9 +52,9 @@ public class SomeService(IDistributedCache cache)
5252
}
5353
```
5454

55-
That's a lot of work to get right each time, including things like serialization. And in the "cache miss" scenario, you could end up with multiple concurrent threads, all getting a cache miss, all fetching the underlying data, all serializing it, and all sending that data to the cache.
55+
The code demonstrates a significant amount of work to get right each time, including things like serialization. Also in the "cache miss" scenario, you might end up with multiple concurrent threads. These threads might all receive a cache miss, all fetch the underlying data, all serialize it, and all send the data to the cache.
5656

57-
Here's equivalent code using `HybridCache`:
57+
Here's equivalent code that uses the `HybridCache` API:
5858

5959
```csharp
6060
public class SomeService(HybridCache cache)
@@ -71,16 +71,16 @@ public class SomeService(HybridCache cache)
7171
}
7272
```
7373

74-
The code is simpler and the library provides stampede protection and other features that `IDistributedCache` doesn't.
74+
The code is simpler, and the library provides stampede protection and other features not available with the `IDistributedCache` interface.
7575

7676
### Compatibility
7777

78-
The `HybridCache` library supports older .NET runtimes, down to .NET Framework 4.7.2 and .NET Standard 2.0.
78+
The `HybridCache` library supports older .NET runtimes, including .NET Framework 4.7.2 and .NET Standard 2.0.
7979

80-
### Additional resources
80+
### More information
8181

8282
For more information, see the following resources:
8383

84-
* <xref:performance/caching/hybrid>
85-
* [Hybrid Cache API proposal (`dotnet/aspnetcore` #54647)](https://github.com/dotnet/aspnetcore/issues/54647)
86-
* [`HybridCache` source code](https://source.dot.net/#Microsoft.Extensions.Caching.Abstractions/Hybrid/HybridCache.cs,8c0fe94693d1ac8d) <!--keep-->
84+
* [HybridCache library in ASP.NET Core](xref:performance/caching/hybrid)
85+
* [Hybrid Cache API proposal (GitHub dotnet/aspnetcore issue #54647)](https://github.com/dotnet/aspnetcore/issues/54647)
86+
* [HybridCache source code](https://source.dot.net/#Microsoft.Extensions.Caching.Abstractions/Hybrid/HybridCache.cs,8c0fe94693d1ac8d) <!--keep-->

0 commit comments

Comments
 (0)