Skip to content

Commit c19f3d2

Browse files
Only look-up Cache-Control once (dotnet#23329)
Only look-up the Cache-Control header once, rather than twice if non-empty.
1 parent cd9da1c commit c19f3d2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Middleware/ResponseCaching/src/ResponseCachingPolicyProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ public virtual bool AttemptResponseCaching(ResponseCachingContext context)
3434
public virtual bool AllowCacheLookup(ResponseCachingContext context)
3535
{
3636
var requestHeaders = context.HttpContext.Request.Headers;
37+
var cacheControl = requestHeaders[HeaderNames.CacheControl];
3738

3839
// Verify request cache-control parameters
39-
if (!StringValues.IsNullOrEmpty(requestHeaders[HeaderNames.CacheControl]))
40+
if (!StringValues.IsNullOrEmpty(cacheControl))
4041
{
41-
if (HeaderUtilities.ContainsCacheDirective(requestHeaders[HeaderNames.CacheControl], CacheControlHeaderValue.NoCacheString))
42+
if (HeaderUtilities.ContainsCacheDirective(cacheControl, CacheControlHeaderValue.NoCacheString))
4243
{
4344
context.Logger.RequestWithNoCacheNotCacheable();
4445
return false;

0 commit comments

Comments
 (0)