Last active
May 20, 2024 22:08
-
-
Save astrarudra/174a3d1c083f75809c8716c620fd8c0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let intervalId; | |
let a = new Date(); | |
let success = 0 | |
const checkVersion = async () => { | |
try { | |
// Append the current timestamp to the URL to prevent caching | |
const response = await fetch(`https://gist.githubusercontent.com/astrarudra/c9a7783d2a4a334a192235d762a27c0d/raw?timestamp=${(new Date()).getTime()}`, { | |
cache: "no-store" // Also try to prevent cache on fetch request | |
}); | |
const data = await response.json(); | |
if (data.version === 13) { | |
success = success + 1 | |
if(success % 100 === 0) { | |
console.log(success + " calls done") | |
} | |
} else { | |
const b = new Date(); | |
const timeDifference = b - a; | |
console.log(b, data.version, `Success=${success} Time Difference: ${timeDifference}ms`); | |
// Clear the interval to stop the repeated execution | |
clearInterval(intervalId); | |
} | |
} catch (error) { | |
const b = new Date(); | |
const timeDifference = b - a; | |
console.error('Error fetching the data:', error); | |
console.log(b, `Success=${success} Time Difference: ${timeDifference}ms`); | |
clearInterval(intervalId); | |
} | |
}; | |
intervalId = setInterval(checkVersion, 1); | |
/* | |
Result | |
14.7k Status 200 - in 59sec / IP | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment