Explorar o código

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

Mfb archive pdf caching gradual rollouts

GitOrigin-RevId: 3a2648d067c0c9cfee04fc6758bd1a5ddb44cd21
Tim Down hai 10 meses
pai
achega
f372fd07f2

+ 7 - 30
services/web/app/src/Features/Compile/CompileController.mjs

@@ -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.
   // Use the query flags from the editor request for overriding the split test.
   let query = {}
   let query = {}
   try {
   try {
@@ -66,8 +58,9 @@ async function _getSplitTestOptions(req, res) {
   const editorReq = { ...req, query }
   const editorReq = { ...req, query }
 
 
   const pdfDownloadDomain = Settings.pdfDownloadDomain
   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.
     // The frontend does not want to do pdf caching.
     return {
     return {
       pdfDownloadDomain,
       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 {
   return {
     pdfDownloadDomain,
     pdfDownloadDomain,
     enablePdfCaching,
     enablePdfCaching,
@@ -181,7 +158,7 @@ const _CompileController = {
     }
     }
 
 
     let { enablePdfCaching, pdfCachingMinChunkSize, pdfDownloadDomain } =
     let { enablePdfCaching, pdfCachingMinChunkSize, pdfDownloadDomain } =
-      await _getSplitTestOptions(req, res)
+      _getSplitTestOptions(req, res)
     if (Features.hasFeature('saas')) {
     if (Features.hasFeature('saas')) {
       options.compileFromClsiCache = true
       options.compileFromClsiCache = true
       options.populateClsiCache = true
       options.populateClsiCache = true

+ 0 - 2
services/web/app/src/Features/Project/ProjectController.mjs

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

+ 4 - 0
services/web/config/settings.defaults.js

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