Skip to content

Instantly share code, notes, and snippets.

@andrioid
Last active August 29, 2015 14:02
Show Gist options
  • Save andrioid/8a23abbbea2adc433279 to your computer and use it in GitHub Desktop.
Save andrioid/8a23abbbea2adc433279 to your computer and use it in GitHub Desktop.
I was playing with RRD and network graphs at home (what do normal people do on holidays?). Anyway... If you include this script in your markup, it will periodically reload all images it can find. For better or worse...
(function() {
function updateImages(){
var images = document.images;
for (var i=0; i<images.length; i++) {
var imagename = images[i].src.match(/((.*)\.(png|gif|jpg))/i);
if (imagename) {
var timestamp = new Date().getTime();
images[i].src = imagename[0] + "?nocache=" + timestamp;
}
}
}
setInterval(function() {
updateImages();
}, 300000); // 5 min
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment