Difference between revisions of "Old images loading Cache issue"
From UnionCloud Support
(Created page with "Add the below to Global JS. This will force all image files to reload. '''It works by adding a parameter in this case the current time to the end of the path. This causes th...") |
(No difference)
|
Latest revision as of 10:07, 7 March 2019
Add the below to Global JS. This will force all image files to reload.
It works by adding a parameter in this case the current time to the end of the path. This causes the browser to treat it as new
There maybe a small delay.
function cacheBuster(url) { return url.replace(/\?cacheBuster=\d*/, "") + "?cacheBuster=" + new Date().getTime().toString(); } $("img").each(function() { this.src = cacheBuster(this.src); }); $("*").each(function() { var bg_img = $(this).css("background-image"); if (bg_img !== "none") { var url = /url\((.*)\)/i.exec(bg_img); if (url) { $(this).css("background-image", "url(" + cacheBuster(url[1]) + ")"); } } });