js: remove 301 redirect cache fix
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 <theo.lebrun@bootlin.com>
This commit is contained in:
parent
9033e80fb2
commit
972fdd73e1
2 changed files with 1 additions and 23 deletions
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/static/script.js?v=15"></script>
|
||||
<script src="/static/script.js?v=16"></script>
|
||||
<script src="/static/dynamic-references.js?v=4"></script>
|
||||
<script src="/static/autocomplete.js" project="{{ current_project }}"></script>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue