From 6154db8f928e6fc04473f19cd4d4fab42cab8b13 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 16 Jan 2023 09:32:12 +0000 Subject: [PATCH] Merge pull request #11236 from overleaf/jpa-pdf-caching-fix-size-estimation [web] pdf-caching: fix estimation of multipart response size GitOrigin-RevId: 5929cc1e413befb3f931889b38a4b21a7ed4cea8 --- .../web/frontend/js/features/pdf-preview/util/pdf-caching.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/features/pdf-preview/util/pdf-caching.js b/services/web/frontend/js/features/pdf-preview/util/pdf-caching.js index 960411cb88..b00fa97f5a 100644 --- a/services/web/frontend/js/features/pdf-preview/util/pdf-caching.js +++ b/services/web/frontend/js/features/pdf-preview/util/pdf-caching.js @@ -10,7 +10,7 @@ const HEADER_OVERHEAD_PER_MULTI_PART_CHUNK = composeMultipartHeader({ start: 9 * 1024 * 1024 * 1024, end: 9 * 1024 * 1024 * 1024, size: 9 * 1024 * 1024 * 1024, -}) +}).length const MULTI_PART_THRESHOLD = 4 const INCREMENTAL_CACHE_SIZE = 1000 // Download large chunks once the shard bandwidth exceeds 50% of their size. @@ -88,7 +88,8 @@ function estimateSizeOfMultipartResponse(chunks) { (totalBytes, chunk) => totalBytes + HEADER_OVERHEAD_PER_MULTI_PART_CHUNK + - (chunk.end - chunk.start) + (chunk.end - chunk.start), + 0 ) + ('\r\n' + SAMPLE_NGINX_BOUNDARY + '--').length ) }