diff --git a/http/script.js b/http/script.js index 337bcb6..984fd8f 100644 --- a/http/script.js +++ b/http/script.js @@ -162,4 +162,23 @@ window.requestAnimationFrame(offsetAnchor) // in case of slow rendering very long pages. window.onload = function () { window.requestAnimationFrame(offsetAnchor) + + // 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 + 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); + } } diff --git a/templates/layout.html b/templates/layout.html index af77b6e..670be27 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -44,7 +44,7 @@ powered by Elixir 2.2 - +