From c48e4be3f57aea1327cd0a07edae0a9774186b07 Mon Sep 17 00:00:00 2001 From: Redet Getachew Date: Sat, 22 Oct 2022 12:58:41 +0300 Subject: [PATCH] Caching API call for 4 hours --- Website/script.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Website/script.js b/Website/script.js index dee2a80eb..9565f457f 100644 --- a/Website/script.js +++ b/Website/script.js @@ -148,9 +148,10 @@ function generateDiv(x) { // Release SECTION ---- let releases = localStorage.getItem("releases"); let releasesRequestedAt = localStorage.getItem("releasesRequestedAt"); -if (parseInt(releasesRequestedAt) > 23) localStorage.removeItem("requestedAt"); // fetch release information every day +if (parseInt(releasesRequestedAt) > 23) localStorage.removeItem("requestedAt"); if (releases == null || releasesRequestedAt == null) getReleases(); -else if (currentHour != releasesRequestedAt) getReleases(); +else if (currentHour - releasesRequestedAt >= 4) + getReleases(); // get release info every 4 hours else updateReleases(); function getReleases() {