mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-29 14:00:05 +02:00

* [web] settle on a single split-test for the clsi-cache rollout Use the split-test that was used for rolling out the writes so that we can use their already populated caches. * [clsi-cache] fix non-sharded clsi-cache in dev-env GitOrigin-RevId: 6ebd6369183342fe6d5e325b760d011fd1d57516
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
import getMeta from '../../../utils/meta'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
|
const hasTextEncoder = typeof TextEncoder !== 'undefined'
|
|
if (!hasTextEncoder) {
|
|
debugConsole.warn('TextEncoder is not available. Disabling pdf-caching.')
|
|
}
|
|
|
|
const isOpera =
|
|
Array.isArray(navigator.userAgentData?.brands) &&
|
|
navigator.userAgentData.brands.some(b => b.brand === 'Opera')
|
|
if (isOpera) {
|
|
debugConsole.warn('Browser cache is limited in Opera. Disabling pdf-caching.')
|
|
}
|
|
|
|
function isFlagEnabled(flag) {
|
|
if (!hasTextEncoder) return false
|
|
if (isOpera) return false
|
|
return getMeta('ol-splitTestVariants')?.[flag] === 'enabled'
|
|
}
|
|
|
|
export const cachedUrlLookupEnabled = isFlagEnabled(
|
|
'pdf-caching-cached-url-lookup'
|
|
)
|
|
export const prefetchingEnabled = isFlagEnabled('pdf-caching-prefetching')
|
|
export const prefetchLargeEnabled = isFlagEnabled('pdf-caching-prefetch-large')
|
|
export const enablePdfCaching = isFlagEnabled('pdf-caching-mode')
|
|
export const trackPdfDownloadEnabled = isFlagEnabled('track-pdf-download')
|
|
export const projectOwnerHasPremiumOnPageLoad = getMeta(
|
|
'ol-projectOwnerHasPremiumOnPageLoad'
|
|
)
|
|
export const fallBackToClsiCache =
|
|
projectOwnerHasPremiumOnPageLoad && isFlagEnabled('populate-clsi-cache')
|