From e7a427dac61e2095163dc9a76a8935a8c870de0d Mon Sep 17 00:00:00 2001 From: Mingze Date: Tue, 8 Oct 2019 13:12:12 -0700 Subject: [PATCH] chore(viewer): Enable GZIP for users in the US (#1082) --- src/lib/viewers/doc/DocBaseViewer.js | 6 ++---- .../viewers/doc/__tests__/DocBaseViewer-test.js | 14 ++------------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/lib/viewers/doc/DocBaseViewer.js b/src/lib/viewers/doc/DocBaseViewer.js index 7e1f2fc07..cbb16578e 100644 --- a/src/lib/viewers/doc/DocBaseViewer.js +++ b/src/lib/viewers/doc/DocBaseViewer.js @@ -657,10 +657,8 @@ class DocBaseViewer extends BaseViewer { // Disable streaming via fetch until performance is improved const disableStream = true; - // Disable range requests for files smaller than MINIMUM_RANGE_REQUEST_FILE_SIZE (25MB) for - // previews outside of the US since the additional latency overhead per range request can be - // more than the additional time for a continuous request. - const isRangeSupported = location.locale === 'en-US' || size >= RANGE_REQUEST_MINIMUM_SIZE; + // Disable range requests for files smaller than MINIMUM_RANGE_REQUEST_FILE_SIZE (25MB) + const isRangeSupported = size >= RANGE_REQUEST_MINIMUM_SIZE; const isWatermarked = watermarkInfo && watermarkInfo.is_watermarked; const disableRange = isWatermarked || !isRangeSupported; diff --git a/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js b/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js index 221afbd00..9755694d8 100644 --- a/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js +++ b/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js @@ -1146,18 +1146,16 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => { }); }); - it('should enable range requests if locale is not en-US, the file is greater than 25MB', () => { + it('should enable range requests if the file is greater than 25MB', () => { docBase.options.file.size = 26500000; - docBase.options.location.locale = 'ja-JP'; return docBase.initViewer('').then(() => { expect(stubs.getDocument).to.be.calledWith(sinon.match({ disableRange: false })); }); }); - it('should disable range requests if locale is not en-US and the file is smaller than 25MB', () => { + it('should disable range requests if the file is smaller than 25MB', () => { docBase.options.file.size = 26000000; - docBase.options.location.locale = 'ja-JP'; return docBase.initViewer('').then(() => { expect(stubs.getDocument).to.be.calledWith(sinon.match({ disableRange: true })); @@ -1174,14 +1172,6 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => { }); }); - it('should not disable range requests if the locale is en-US', () => { - docBase.options.location.locale = 'en-US'; - - return docBase.initViewer('').then(() => { - expect(stubs.getDocument).to.be.calledWith(sinon.match({ disableRange: false })); - }); - }); - it('should set disableCreateObjectURL to false', () => { return docBase.initViewer('').then(() => { expect(stubs.getDocument).to.be.calledWith(sinon.match({ disableCreateObjectURL: false }));