Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit fe6ef55

Browse files
committed
Feedback
1 parent fac6a06 commit fe6ef55

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class ResponseCachingContext
2323
private CacheControlHeaderValue _requestCacheControl;
2424
private CacheControlHeaderValue _responseCacheControl;
2525
private DateTimeOffset _responseTime;
26+
private static readonly CacheControlHeaderValue EmptyCacheControl = new CacheControlHeaderValue();
2627

2728
public ResponseCachingContext(HttpContext httpContext, IResponseCache cache)
2829
{
@@ -78,7 +79,7 @@ private CacheControlHeaderValue RequestCacheControl
7879
{
7980
if (_requestCacheControl == null)
8081
{
81-
_requestCacheControl = RequestHeaders.CacheControl ?? new CacheControlHeaderValue();
82+
_requestCacheControl = RequestHeaders.CacheControl ?? EmptyCacheControl;
8283
}
8384
return _requestCacheControl;
8485
}
@@ -90,7 +91,7 @@ private CacheControlHeaderValue ResponseCacheControl
9091
{
9192
if (_responseCacheControl == null)
9293
{
93-
_responseCacheControl = ResponseHeaders.CacheControl ?? new CacheControlHeaderValue();
94+
_responseCacheControl = ResponseHeaders.CacheControl ?? EmptyCacheControl;
9495
}
9596
return _responseCacheControl;
9697
}
@@ -249,7 +250,7 @@ private bool ValidateEncoding(ResponseHeaders cachedResponsHeaders)
249250

250251
private bool EntryIsFresh(ResponseHeaders responseHeaders, TimeSpan age, bool verifyAgainstRequest)
251252
{
252-
var responseCacheControl = responseHeaders.CacheControl ?? new CacheControlHeaderValue();
253+
var responseCacheControl = responseHeaders.CacheControl ?? EmptyCacheControl;
253254

254255
// Add min-fresh requirements
255256
if (verifyAgainstRequest)
@@ -329,7 +330,6 @@ internal async Task<bool> TryServeFromCacheAsync()
329330

330331
if (_responseType == ResponseType.HeadersOnly)
331332
{
332-
response.ContentLength = 0;
333333
responseServed = true;
334334
}
335335
else if (_responseType == ResponseType.FullReponse)

0 commit comments

Comments
 (0)