Skip to content

Instantly share code, notes, and snippets.

@CarlRevell
Created December 30, 2013 15:52
Show Gist options
  • Save CarlRevell/8183745 to your computer and use it in GitHub Desktop.
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.
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