From 7f0e981e06b1d44444f2cace3e37c209d14f2f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Lebrun?= Date: Thu, 19 Dec 2024 17:20:00 +0100 Subject: [PATCH] js: remove 301 redirect cache fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code was required because we messed-up in the past regarding caching headers. This is not required anymore because the caching set has expired, so no well behaving user-agent should have remains. This represents something like 240k requests to the backend (not the cache) over two weeks. Server load was minimal because generating those responses is really fast. Signed-off-by: Théo Lebrun --- static/script.js | 22 ---------------------- templates/layout.html | 2 +- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/static/script.js b/static/script.js index 426dfd94..00bf82cb 100644 --- a/static/script.js +++ b/static/script.js @@ -319,27 +319,6 @@ function setupGoToTop() { }); } -// fix incorrectly issued 301 redirect -// https://developer.mozilla.org/en-US/docs/Web/API/Request/cache -// https://developer.mozilla.org/en-US/docs/Web/API/Request/redirect -// TODO: remove after 10.2024 -function fix301() { - let path = location.pathname.split('/'); - if (path.length == 4) { - path[2] = 'latest'; - let newPath = path.join('/'); - fetch(newPath, { - cache: 'reload', - redirect: 'manual', - // this is to make sure that varnish will cache the response, - // by default fetch sends no-cache in both headers if cache='reload' - headers: {'Cache-Control': 'max-age=86400', 'Pragma': ''} - }) - .then(console.log) - .catch(console.error); - } -} - function randomChoice(arr) { return arr[Math.floor(Math.random() * arr.length)]; } @@ -425,5 +404,4 @@ document.addEventListener('DOMContentLoaded', _ => { setupAutoscrollingPrevention(); setupAnchorOffsetHandler(); setupGoToTop(); - fix301(); }); diff --git a/templates/layout.html b/templates/layout.html index c4266c1e..0818a76b 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -75,7 +75,7 @@ - +