Skip to content

Commit

Permalink
Caching API call for 4 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
redet-G committed Oct 22, 2022
1 parent 9c0b23b commit c48e4be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Website/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c48e4be

Please sign in to comment.