Skip to content

Commit 4013de5

Browse files
committed
PR feedback
1 parent edaf9ff commit 4013de5

15 files changed

+76
-244
lines changed

src/Middleware/OutputCaching/samples/OutputCachingSample/OutputCachingSample.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<Reference Include="Microsoft.AspNetCore.OutputCaching" />
109
<Reference Include="Microsoft.AspNetCore" />
11-
<Reference Include="Microsoft.AspNetCore.Diagnostics" />
12-
<Reference Include="Microsoft.AspNetCore.Hosting" />
13-
<Reference Include="Microsoft.AspNetCore.Http" />
14-
<Reference Include="Microsoft.AspNetCore.Http.Results" />
1510
<!-- Mvc.Core is referenced only for its attributes -->
1611
<Reference Include="Microsoft.AspNetCore.Mvc.Core" />
17-
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
1812
</ItemGroup>
1913

2014
</Project>

src/Middleware/OutputCaching/src/IOutputCacheStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ public interface IOutputCacheStore
3232
/// <param name="tags">The tags associated with the cache entry to store.</param>
3333
/// <param name="validFor">The amount of time the entry will be kept in the cache before expiring, relative to now.</param>
3434
/// <param name="cancellationToken">Indicates that the operation should be cancelled.</param>
35-
ValueTask SetAsync(string key, byte[] value, string[] tags, TimeSpan validFor, CancellationToken cancellationToken);
35+
ValueTask SetAsync(string key, byte[] value, string[]? tags, TimeSpan validFor, CancellationToken cancellationToken);
3636
}

src/Middleware/OutputCaching/src/LoggerExtensions.cs

Lines changed: 17 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Microsoft.AspNetCore.OutputCaching;
88

99
/// <summary>
10-
/// Defines *all* the logger messages produced by response caching
10+
/// Defines the logger messages produced by output caching
1111
/// </summary>
1212
internal static partial class LoggerExtensions
1313
{
@@ -19,109 +19,51 @@ internal static partial class LoggerExtensions
1919
EventName = "RequestWithAuthorizationNotCacheable")]
2020
internal static partial void RequestWithAuthorizationNotCacheable(this ILogger logger);
2121

22-
[LoggerMessage(3, LogLevel.Debug, "The request cannot be served from cache because it contains a 'no-cache' cache directive.",
23-
EventName = "RequestWithNoCacheNotCacheable")]
24-
internal static partial void RequestWithNoCacheNotCacheable(this ILogger logger);
25-
26-
[LoggerMessage(4, LogLevel.Debug, "The request cannot be served from cache because it contains a 'no-cache' pragma directive.",
27-
EventName = "RequestWithPragmaNoCacheNotCacheable")]
28-
internal static partial void RequestWithPragmaNoCacheNotCacheable(this ILogger logger);
29-
30-
[LoggerMessage(5, LogLevel.Debug, "Adding a minimum freshness requirement of {Duration} specified by the 'min-fresh' cache directive.",
31-
EventName = "LogRequestMethodNotCacheable")]
32-
internal static partial void ExpirationMinFreshAdded(this ILogger logger, TimeSpan duration);
33-
34-
[LoggerMessage(6, LogLevel.Debug, "The age of the entry is {Age} and has exceeded the maximum age for shared caches of {SharedMaxAge} specified by the 's-maxage' cache directive.",
35-
EventName = "ExpirationSharedMaxAgeExceeded")]
36-
internal static partial void ExpirationSharedMaxAgeExceeded(this ILogger logger, TimeSpan age, TimeSpan sharedMaxAge);
37-
38-
[LoggerMessage(7, LogLevel.Debug, "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. " +
39-
"It must be revalidated because the 'must-revalidate' or 'proxy-revalidate' cache directive is specified.",
40-
EventName = "ExpirationMustRevalidate")]
41-
internal static partial void ExpirationMustRevalidate(this ILogger logger, TimeSpan age, TimeSpan maxAge);
42-
43-
[LoggerMessage(8, LogLevel.Debug, "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. " +
44-
"However, it satisfied the maximum stale allowance of {MaxStale} specified by the 'max-stale' cache directive.",
45-
EventName = "ExpirationMaxStaleSatisfied")]
46-
internal static partial void ExpirationMaxStaleSatisfied(this ILogger logger, TimeSpan age, TimeSpan maxAge, TimeSpan maxStale);
47-
48-
[LoggerMessage(9, LogLevel.Debug, "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive.", EventName = "ExpirationMaxAgeExceeded")]
49-
internal static partial void ExpirationMaxAgeExceeded(this ILogger logger, TimeSpan age, TimeSpan maxAge);
50-
51-
[LoggerMessage(10, LogLevel.Debug, "The response time of the entry is {ResponseTime} and has exceeded its expiry date of {Expired} specified by the 'Expires' header.",
52-
EventName = "ExpirationExpiresExceeded")]
53-
internal static partial void ExpirationExpiresExceeded(this ILogger logger, DateTimeOffset responseTime, DateTimeOffset expired);
54-
55-
[LoggerMessage(11, LogLevel.Debug, "Response is not cacheable because it does not contain the 'public' cache directive.",
56-
EventName = "ResponseWithoutPublicNotCacheable")]
57-
internal static partial void ResponseWithoutPublicNotCacheable(this ILogger logger);
58-
59-
[LoggerMessage(12, LogLevel.Debug, "Response is not cacheable because it or its corresponding request contains a 'no-store' cache directive.",
60-
EventName = "ResponseWithNoStoreNotCacheable")]
61-
internal static partial void ResponseWithNoStoreNotCacheable(this ILogger logger);
62-
[LoggerMessage(13, LogLevel.Debug, "Response is not cacheable because it contains a 'no-cache' cache directive.",
63-
EventName = "ResponseWithNoCacheNotCacheable")]
64-
internal static partial void ResponseWithNoCacheNotCacheable(this ILogger logger);
65-
66-
[LoggerMessage(14, LogLevel.Debug, "Response is not cacheable because it contains a 'SetCookie' header.", EventName = "ResponseWithSetCookieNotCacheable")]
22+
[LoggerMessage(3, LogLevel.Debug, "Response is not cacheable because it contains a 'SetCookie' header.", EventName = "ResponseWithSetCookieNotCacheable")]
6723
internal static partial void ResponseWithSetCookieNotCacheable(this ILogger logger);
6824

69-
[LoggerMessage(15, LogLevel.Debug, "Response is not cacheable because it contains a '.Vary' header with a value of *.",
70-
EventName = "ResponseWithVaryStarNotCacheable")]
71-
internal static partial void ResponseWithVaryStarNotCacheable(this ILogger logger);
72-
73-
[LoggerMessage(16, LogLevel.Debug, "Response is not cacheable because it contains the 'private' cache directive.",
74-
EventName = "ResponseWithPrivateNotCacheable")]
75-
internal static partial void ResponseWithPrivateNotCacheable(this ILogger logger);
76-
77-
[LoggerMessage(17, LogLevel.Debug, "Response is not cacheable because its status code {StatusCode} does not indicate success.",
25+
[LoggerMessage(4, LogLevel.Debug, "Response is not cacheable because its status code {StatusCode} does not indicate success.",
7826
EventName = "ResponseWithUnsuccessfulStatusCodeNotCacheable")]
7927
internal static partial void ResponseWithUnsuccessfulStatusCodeNotCacheable(this ILogger logger, int statusCode);
8028

81-
[LoggerMessage(18, LogLevel.Debug, "The 'IfNoneMatch' header of the request contains a value of *.", EventName = "ExpirationExpiresExceeded")]
29+
[LoggerMessage(5, LogLevel.Debug, "The 'IfNoneMatch' header of the request contains a value of *.", EventName = "NotModifiedIfNoneMatchStar")]
8230
internal static partial void NotModifiedIfNoneMatchStar(this ILogger logger);
8331

84-
[LoggerMessage(19, LogLevel.Debug, "The ETag {ETag} in the 'IfNoneMatch' header matched the ETag of a cached entry.",
32+
[LoggerMessage(6, LogLevel.Debug, "The ETag {ETag} in the 'IfNoneMatch' header matched the ETag of a cached entry.",
8533
EventName = "NotModifiedIfNoneMatchMatched")]
8634
internal static partial void NotModifiedIfNoneMatchMatched(this ILogger logger, EntityTagHeaderValue etag);
8735

88-
[LoggerMessage(20, LogLevel.Debug, "The last modified date of {LastModified} is before the date {IfModifiedSince} specified in the 'IfModifiedSince' header.",
36+
[LoggerMessage(7, LogLevel.Debug, "The last modified date of {LastModified} is before the date {IfModifiedSince} specified in the 'IfModifiedSince' header.",
8937
EventName = "NotModifiedIfModifiedSinceSatisfied")]
9038
internal static partial void NotModifiedIfModifiedSinceSatisfied(this ILogger logger, DateTimeOffset lastModified, DateTimeOffset ifModifiedSince);
9139

92-
[LoggerMessage(21, LogLevel.Information, "The content requested has not been modified.", EventName = "NotModifiedServed")]
40+
[LoggerMessage(8, LogLevel.Information, "The content requested has not been modified.", EventName = "NotModifiedServed")]
9341
internal static partial void NotModifiedServed(this ILogger logger);
9442

95-
[LoggerMessage(22, LogLevel.Information, "Serving response from cache.", EventName = "CachedResponseServed")]
43+
[LoggerMessage(9, LogLevel.Information, "Serving response from cache.", EventName = "CachedResponseServed")]
9644
internal static partial void CachedResponseServed(this ILogger logger);
9745

98-
[LoggerMessage(23, LogLevel.Information, "No cached response available for this request and the 'only-if-cached' cache directive was specified.",
46+
[LoggerMessage(10, LogLevel.Information, "No cached response available for this request and the 'only-if-cached' cache directive was specified.",
9947
EventName = "GatewayTimeoutServed")]
10048
internal static partial void GatewayTimeoutServed(this ILogger logger);
10149

102-
[LoggerMessage(24, LogLevel.Information, "No cached response available for this request.", EventName = "NoResponseServed")]
50+
[LoggerMessage(11, LogLevel.Information, "No cached response available for this request.", EventName = "NoResponseServed")]
10351
internal static partial void NoResponseServed(this ILogger logger);
10452

105-
[LoggerMessage(25, LogLevel.Debug, "Vary by rules were updated. Headers: {Headers}, Query keys: {QueryKeys}", EventName = "VaryByRulesUpdated")]
53+
[LoggerMessage(12, LogLevel.Debug, "Vary by rules were updated. Headers: {Headers}, Query keys: {QueryKeys}", EventName = "VaryByRulesUpdated")]
10654
internal static partial void VaryByRulesUpdated(this ILogger logger, string headers, string queryKeys);
10755

108-
[LoggerMessage(26, LogLevel.Information, "The response has been cached.", EventName = "ResponseCached")]
56+
[LoggerMessage(13, LogLevel.Information, "The response has been cached.", EventName = "ResponseCached")]
10957
internal static partial void ResponseCached(this ILogger logger);
11058

111-
[LoggerMessage(27, LogLevel.Information, "The response could not be cached for this request.", EventName = "ResponseNotCached")]
112-
internal static partial void LogResponseNotCached(this ILogger logger);
59+
[LoggerMessage(14, LogLevel.Information, "The response could not be cached for this request.", EventName = "ResponseNotCached")]
60+
internal static partial void ResponseNotCached(this ILogger logger);
11361

114-
[LoggerMessage(28, LogLevel.Warning, "The response could not be cached for this request because the 'Content-Length' did not match the body length.",
115-
EventName = "responseContentLengthMismatchNotCached")]
62+
[LoggerMessage(15, LogLevel.Warning, "The response could not be cached for this request because the 'Content-Length' did not match the body length.",
63+
EventName = "ResponseContentLengthMismatchNotCached")]
11664
internal static partial void ResponseContentLengthMismatchNotCached(this ILogger logger);
11765

118-
[LoggerMessage(29, LogLevel.Debug,
119-
"The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. " +
120-
"However, the 'max-stale' cache directive was specified without an assigned value and a stale response of any age is accepted.",
121-
EventName = "ExpirationInfiniteMaxStaleSatisfied")]
122-
internal static partial void ExpirationInfiniteMaxStaleSatisfied(this ILogger logger, TimeSpan age, TimeSpan maxAge);
123-
124-
[LoggerMessage(30, LogLevel.Debug, "The response time of the entry is {ResponseTime} and has exceeded its expiry date.",
66+
[LoggerMessage(16, LogLevel.Debug, "The response time of the entry is {ResponseTime} and has exceeded its expiry date.",
12567
EventName = "ExpirationExpiresExceeded")]
12668
internal static partial void ExpirationExpiresExceeded(this ILogger logger, DateTimeOffset responseTime);
12769

src/Middleware/OutputCaching/src/Memory/MemoryOutputCacheStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public ValueTask EvictByTagAsync(string tag, CancellationToken cancellationToken
4343
}
4444

4545
/// <inheritdoc />
46-
public ValueTask SetAsync(string key, byte[] value, string[] tags, TimeSpan validFor, CancellationToken cancellationToken)
46+
public ValueTask SetAsync(string key, byte[] value, string[]? tags, TimeSpan validFor, CancellationToken cancellationToken)
4747
{
4848
ArgumentNullException.ThrowIfNull(key);
4949
ArgumentNullException.ThrowIfNull(value);

src/Middleware/OutputCaching/src/Microsoft.AspNetCore.OutputCaching.csproj

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
66
<IsAspNetCoreApp>true</IsAspNetCoreApp>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
9-
<PackageTags>aspnetcore;cache;caching</PackageTags>
108
<IsPackable>false</IsPackable>
119
<IsTrimmable>true</IsTrimmable>
1210
</PropertyGroup>
1311

12+
<ItemGroup>
13+
<InternalsVisibleTo Include="Microsoft.AspNetCore.OutputCaching.Tests" />
14+
</ItemGroup>
15+
1416
<ItemGroup>
1517
<Reference Include="Microsoft.AspNetCore.Http.Extensions" />
1618
<Reference Include="Microsoft.AspNetCore.Http" />
@@ -22,19 +24,4 @@
2224
<Compile Include="$(RepoRoot)src\Shared\TaskToApm.cs" Link="Streams\TaskToApm.cs" />
2325
</ItemGroup>
2426

25-
<ItemGroup>
26-
<Compile Update="Resources.Designer.cs">
27-
<DesignTime>True</DesignTime>
28-
<AutoGen>True</AutoGen>
29-
<DependentUpon>Resources.resx</DependentUpon>
30-
</Compile>
31-
</ItemGroup>
32-
33-
<ItemGroup>
34-
<EmbeddedResource Update="Resources.resx">
35-
<Generator>ResXFileCodeGenerator</Generator>
36-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
37-
</EmbeddedResource>
38-
</ItemGroup>
39-
4027
</Project>

src/Middleware/OutputCaching/src/OutputCacheMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ internal async ValueTask FinalizeCacheBodyAsync(OutputCacheContext context)
453453
}
454454
else
455455
{
456-
_logger.LogResponseNotCached();
456+
_logger.ResponseNotCached();
457457
}
458458
}
459459

src/Middleware/OutputCaching/src/Policies/LockingPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private LockingPolicy(bool lockResponse)
2121
public static readonly LockingPolicy Enabled = new(true);
2222

2323
/// <summary>
24-
/// A policy that disabled locking/
24+
/// A policy that disables locking.
2525
/// </summary>
2626
public static readonly LockingPolicy Disabled = new(false);
2727

src/Middleware/OutputCaching/src/Policies/NoLookupPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Microsoft.AspNetCore.OutputCaching;
55

66
/// <summary>
7-
/// A policy that prevents the response from being served from cached.
7+
/// A policy that prevents the response from being served from cache.
88
/// </summary>
99
internal sealed class NoLookupPolicy : IOutputCachePolicy
1010
{

src/Middleware/OutputCaching/src/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Middleware/OutputCaching/src/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Microsoft.AspNetCore.OutputCaching.IOutputCacheStore
1818
Microsoft.AspNetCore.OutputCaching.IOutputCacheStore.EvictByTagAsync(string! tag, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask
1919
Microsoft.AspNetCore.OutputCaching.IOutputCachePolicy
2020
Microsoft.AspNetCore.OutputCaching.IOutputCacheStore.GetAsync(string! key, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<byte[]?>
21-
Microsoft.AspNetCore.OutputCaching.IOutputCacheStore.SetAsync(string! key, byte[]! value, string![]! tags, System.TimeSpan validFor, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask
21+
Microsoft.AspNetCore.OutputCaching.IOutputCacheStore.SetAsync(string! key, byte[]! value, string![]? tags, System.TimeSpan validFor, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask
2222
Microsoft.AspNetCore.OutputCaching.OutputCacheAttribute
2323
Microsoft.AspNetCore.OutputCaching.OutputCacheAttribute.Duration.get -> int
2424
Microsoft.AspNetCore.OutputCaching.OutputCacheAttribute.Duration.init -> void

src/Middleware/OutputCaching/src/Resources.Designer.cs

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)