@@ -322,31 +322,23 @@ internal void FinalizeCacheHeaders(ResponseCachingContext context)
322
322
{
323
323
if ( OnFinalizeCacheHeaders ( context ) )
324
324
{
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 ) ) ;
334
330
}
335
331
}
336
332
337
333
internal Task FinalizeCacheHeadersAsync ( ResponseCachingContext context )
338
334
{
339
335
if ( OnFinalizeCacheHeaders ( context ) )
340
336
{
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 ) ) ;
350
342
}
351
343
return Task . CompletedTask ;
352
344
}
@@ -369,15 +361,11 @@ internal async Task FinalizeCacheBodyAsync(ResponseCachingContext context)
369
361
context . CachedResponse . Body = bufferStream ;
370
362
_logger . LogResponseCached ( ) ;
371
363
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 ) ) ;
381
369
}
382
370
else
383
371
{
@@ -569,7 +557,7 @@ internal static long EstimateCachedResponseSize(CachedResponse cachedResponse)
569
557
// Body
570
558
if ( cachedResponse . Body != null )
571
559
{
572
- size += cachedResponse . Body . Length * sizeof ( char ) ;
560
+ size += cachedResponse . Body . Length ;
573
561
}
574
562
575
563
return size ;
0 commit comments