Merge pull request #29869 from overleaf/mfb-archive-pdf-caching-gradual-rollouts

Mfb archive pdf caching gradual rollouts

GitOrigin-RevId: 3a2648d067c0c9cfee04fc6758bd1a5ddb44cd21
This commit is contained in:
Tim Down
2025-12-03 14:36:19 +00:00
committed by Copybot
parent 5bbc5b2e58
commit f372fd07f2
3 changed files with 11 additions and 32 deletions

View File

@@ -44,19 +44,11 @@ function getOutputFilesArchiveSpecification(projectId, userId, buildId) {
}
}
async function getPdfCachingMinChunkSize(req, res) {
const { variant } = await SplitTestHandler.promises.getAssignment(
req,
res,
'pdf-caching-min-chunk-size'
)
if (variant === 'default') {
return 1_000_000
}
return parseInt(variant, 10)
function getPdfCachingMinChunkSize(req, res) {
return Settings.pdfCachingMinChunkSize
}
async function _getSplitTestOptions(req, res) {
function _getSplitTestOptions(req, res) {
// Use the query flags from the editor request for overriding the split test.
let query = {}
try {
@@ -66,8 +58,9 @@ async function _getSplitTestOptions(req, res) {
const editorReq = { ...req, query }
const pdfDownloadDomain = Settings.pdfDownloadDomain
const enablePdfCaching = Settings.enablePdfCaching
if (!req.query.enable_pdf_caching) {
if (!enablePdfCaching || !req.query.enable_pdf_caching) {
// The frontend does not want to do pdf caching.
return {
pdfDownloadDomain,
@@ -75,23 +68,7 @@ async function _getSplitTestOptions(req, res) {
}
}
// Double check with the latest split test assignment.
// We may need to turn off the feature on a short notice, without requiring
// all users to reload their editor page to disable the feature.
const { variant } = await SplitTestHandler.promises.getAssignment(
editorReq,
res,
'pdf-caching-mode'
)
const enablePdfCaching = variant === 'enabled'
if (!enablePdfCaching) {
// Skip the lookup of the chunk size when caching is not enabled.
return {
pdfDownloadDomain,
enablePdfCaching: false,
}
}
const pdfCachingMinChunkSize = await getPdfCachingMinChunkSize(editorReq, res)
const pdfCachingMinChunkSize = getPdfCachingMinChunkSize(editorReq, res)
return {
pdfDownloadDomain,
enablePdfCaching,
@@ -181,7 +158,7 @@ const _CompileController = {
}
let { enablePdfCaching, pdfCachingMinChunkSize, pdfDownloadDomain } =
await _getSplitTestOptions(req, res)
_getSplitTestOptions(req, res)
if (Features.hasFeature('saas')) {
options.compileFromClsiCache = true
options.populateClsiCache = true

View File

@@ -435,8 +435,6 @@ const _ProjectController = {
'visual-preview',
'external-socket-heartbeat',
'null-test-share-modal',
'pdf-caching-cached-url-lookup',
'pdf-caching-mode',
'pdf-caching-prefetch-large',
'pdf-caching-prefetching',
'revert-file',

View File

@@ -703,6 +703,10 @@ module.exports = {
// By default turn on feature flag, can be overridden per request.
enablePdfCaching: process.env.ENABLE_PDF_CACHING === 'true',
pdfCachingMinChunkSize: 7500,
pdfCaching: true,
cachedUrlLookupEnabled: true,
// Maximum size of text documents in the real-time editing system.
max_doc_length: 2 * 1024 * 1024, // 2mb