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

Commit 7372712

Browse files
committed
Feedback
1 parent cbb9833 commit 7372712

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingMiddleware.cs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -322,31 +322,23 @@ internal void FinalizeCacheHeaders(ResponseCachingContext context)
322322
{
323323
if (OnFinalizeCacheHeaders(context))
324324
{
325-
try
326-
{
327-
_cache.Set(
328-
context.BaseKey,
329-
context.CachedVaryByRules,
330-
context.CachedResponseValidFor,
331-
EstimateCachedVaryByRulesySize(context.CachedVaryByRules));
332-
}
333-
catch (OverflowException) { }
325+
_cache.Set(
326+
context.BaseKey,
327+
context.CachedVaryByRules,
328+
context.CachedResponseValidFor,
329+
EstimateCachedVaryByRulesySize(context.CachedVaryByRules));
334330
}
335331
}
336332

337333
internal Task FinalizeCacheHeadersAsync(ResponseCachingContext context)
338334
{
339335
if (OnFinalizeCacheHeaders(context))
340336
{
341-
try
342-
{
343-
return _cache.SetAsync(
344-
context.BaseKey,
345-
context.CachedVaryByRules,
346-
context.CachedResponseValidFor,
347-
EstimateCachedVaryByRulesySize(context.CachedVaryByRules));
348-
}
349-
catch (OverflowException) { }
337+
return _cache.SetAsync(
338+
context.BaseKey,
339+
context.CachedVaryByRules,
340+
context.CachedResponseValidFor,
341+
EstimateCachedVaryByRulesySize(context.CachedVaryByRules));
350342
}
351343
return Task.CompletedTask;
352344
}
@@ -369,15 +361,11 @@ internal async Task FinalizeCacheBodyAsync(ResponseCachingContext context)
369361
context.CachedResponse.Body = bufferStream;
370362
_logger.LogResponseCached();
371363

372-
try
373-
{
374-
await _cache.SetAsync(
375-
context.StorageVaryKey ?? context.BaseKey,
376-
context.CachedResponse,
377-
context.CachedResponseValidFor,
378-
EstimateCachedResponseSize(context.CachedResponse));
379-
}
380-
catch (OverflowException) { }
364+
await _cache.SetAsync(
365+
context.StorageVaryKey ?? context.BaseKey,
366+
context.CachedResponse,
367+
context.CachedResponseValidFor,
368+
EstimateCachedResponseSize(context.CachedResponse));
381369
}
382370
else
383371
{
@@ -569,7 +557,7 @@ internal static long EstimateCachedResponseSize(CachedResponse cachedResponse)
569557
// Body
570558
if (cachedResponse.Body != null)
571559
{
572-
size += cachedResponse.Body.Length * sizeof(char);
560+
size += cachedResponse.Body.Length;
573561
}
574562

575563
return size;

0 commit comments

Comments
 (0)