Created
December 30, 2013 15:52
-
-
Save CarlRevell/8183745 to your computer and use it in GitHub Desktop.
Returns the same cache buster value for a given number of minutes. I use it by appending '&cb=' + cacheBusterMinutes(5) for example to ensure the same URL is used for 5 minutes and then changes after 5 minutes with a different &cb querystring value.
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
function cacheBusterMinutes(cache_for_minutes) { | |
var d = new Date; | |
return d.getFullYear() + ("0" + d.getMonth()).slice(-2) + ("0" + d.getDate()).slice(-2) + ("0" + d.getHours()).slice(-2) + ("0" + parseInt(d.getMinutes() / cache_for_minutes)).slice(-2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment