From cb2434d29c2db518550adde0518e76b9b20149e5 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 16 Aug 2024 09:06:17 +0100 Subject: [PATCH] Merge pull request #19777 from overleaf/bg-issue19430-implement-wiki-caching support conditional requests for learn wiki images GitOrigin-RevId: fb77ab632c325f88dfed1624a5abad8f2e52ee3d --- services/web/app/src/infrastructure/Server.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/web/app/src/infrastructure/Server.js b/services/web/app/src/infrastructure/Server.js index 6c6ffffeeb..f9f7274401 100644 --- a/services/web/app/src/infrastructure/Server.js +++ b/services/web/app/src/infrastructure/Server.js @@ -297,6 +297,12 @@ webRouter.use(function addNoCacheHeader(req, res, next) { return next() } + const isWikiContent = /^\/learn(-scripts)?(\/|$)/i.test(req.path) + if (isWikiContent) { + // don't set no-cache headers on wiki content, as it's immutable and can be cached (publicly) + return next() + } + const isLoggedIn = SessionManager.isUserLoggedIn(req.session) if (isLoggedIn) { // always set no-cache headers for authenticated users (apart from project files, above)