From b4da29dd369a9a4267ba8e08c973ca81248da79f Mon Sep 17 00:00:00 2001 From: Milan Date: Thu, 23 Mar 2023 22:15:12 +0100 Subject: [PATCH] default.js: add parseUrl Users were seeing outdated content due to browser caching. To resolve this issue, a unique random value is now added to the end of each URL every time the page is loaded, forcing the browser to retrieve the latest version of the page from the server. By implementing this solution, users will be able to see the most recent content without any delay caused by outdated cache files. --- website/agenda/planung/js/default.js | 18 ++++++++++++++++-- website/agenda/planung/js/select-event.js | 2 ++ website/agenda/planung/js/select-series.js | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/website/agenda/planung/js/default.js b/website/agenda/planung/js/default.js index c8c05bf..3cc64d7 100644 --- a/website/agenda/planung/js/default.js +++ b/website/agenda/planung/js/default.js @@ -78,14 +78,28 @@ function contains(s,t){ } function updateContainer(id, url, callback){ - //alert(id+":"+url); if (id==null) return; if ($("#"+id).length==0) return; + url = parseUrl(url); $("#"+id).load(url, callback); } function load(url){ - window.location=url; + window.location = parseUrl(url); +} + +function parseUrl(uri){ + if (uri.startsWith("/")) { + uri = window.location.origin + uri; + } else if (!uri.startsWith("http")) { + var path = window.location.pathname.replace(/\/$/, ""); + path = path.split("/"); + path.pop(); + uri = window.location.origin + path.join("/") + "/" + uri; + } + var url = new URL(uri); + url.searchParams.append("_", Date.now()); + return url.toString(); } function postContainer(url, parameters, callback){ diff --git a/website/agenda/planung/js/select-event.js b/website/agenda/planung/js/select-event.js index 388d7a7..fae2eaa 100644 --- a/website/agenda/planung/js/select-event.js +++ b/website/agenda/planung/js/select-event.js @@ -83,6 +83,8 @@ function updateEventSelection(resultElemId){ } var elem=$("#selectEvent").parent(); + url = parseUrl(url); + console.log(url); $(elem).load(url); } diff --git a/website/agenda/planung/js/select-series.js b/website/agenda/planung/js/select-series.js index 9e130c1..f1b4fb8 100644 --- a/website/agenda/planung/js/select-series.js +++ b/website/agenda/planung/js/select-series.js @@ -36,7 +36,9 @@ function updateSeriesSelection(resultElemId){ url+="&selectProjectStudio=1"; } + url = parseUrl(url); var elem=$("#selectSeries").parent(); + console.log(url); $(elem).load(url); }