Skip to content

Commit

Permalink
♻️ Add config for cache time, local time
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Dec 6, 2020
1 parent 9177df4 commit 130394c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/createOctokit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export const cachedResponse = async (key, fn) => {
const data = localStorage.getItem(key);
if (data) {
const item = JSON.parse(data);
if (new Date().getTime() - new Date(item.createdAt || "").getTime() > 600000) {
if (
new Date().getTime() - new Date(item.createdAt || "").getTime() >
(document.domain === "localhost"
? config["status-website"].localhostCacheTime || 3600000
: config["status-website"].productionCacheTime || 120000)
) {
localStorage.removeItem(key);
} else {
console.log("Got cached item");
Expand Down

0 comments on commit 130394c

Please sign in to comment.