Merge pull request #8641 from overleaf/jpa-pdf-caching-refresh

[web] serviceWorker: add support for zonal pdf downloads

GitOrigin-RevId: 490ff38ded19ebe32755b708e6ac270babfa519f
This commit is contained in:
Jakob Ackermann 2022-06-30 10:27:09 +01:00 committed by Copybot
parent da02a4f2be
commit 9fba03e70a

View file

@ -8,7 +8,8 @@ const VERSION = 2
const CLEAR_CACHE_REQUEST_MATCHER = /^\/project\/[0-9a-f]{24}\/output$/ const CLEAR_CACHE_REQUEST_MATCHER = /^\/project\/[0-9a-f]{24}\/output$/
const COMPILE_REQUEST_MATCHER = /^\/project\/[0-9a-f]{24}\/compile$/ const COMPILE_REQUEST_MATCHER = /^\/project\/[0-9a-f]{24}\/compile$/
const PDF_REQUEST_MATCHER = /^\/project\/[0-9a-f]{24}\/.*\/output.pdf$/ const PDF_REQUEST_MATCHER =
/^(\/zone\/.)?(\/project\/[0-9a-f]{24}\/.*\/output.pdf)$/
const PDF_JS_CHUNK_SIZE = 128 * 1024 const PDF_JS_CHUNK_SIZE = 128 * 1024
const MAX_SUBREQUEST_COUNT = 4 const MAX_SUBREQUEST_COUNT = 4
const MAX_SUBREQUEST_BYTES = 4 * PDF_JS_CHUNK_SIZE const MAX_SUBREQUEST_BYTES = 4 * PDF_JS_CHUNK_SIZE
@ -162,8 +163,9 @@ function onFetch(event) {
return processCompileRequest(event) return processCompileRequest(event)
} }
if (path.match(PDF_REQUEST_MATCHER)) { const match = path.match(PDF_REQUEST_MATCHER)
const ctx = getPdfContext(event.clientId, path) if (match) {
const ctx = getPdfContext(event.clientId, match[2])
if (ctx) { if (ctx) {
return processPdfRequest(event, ctx) return processPdfRequest(event, ctx)
} }