sharepoint - How to prevent browser image caching in HTML -
looking on html issue running images caching on browsers.
scenario:
i using html code build out custom page on sharepoint online. html code embedded content editor web part. have image link points file called "article-photo.jpg" , updated marketing department using same file name.
right now, when overwrite file stored in site assets library in sharepoint, different image using same file name, close out of internet explorer , head sharepoint site, old image still appears. until hit refresh button when new image appears on screen. in google chrome, image not update @ when hit f5 refresh. have use shift+f5 perform full refresh , image updates.
i not using meta tags in header of html code. img src using absolute path image located in site assets library. html file contains css brand page, looking see if can throw header of file prevent image caching on browsers.
thanks this, dave
expanding on previous comments, add image time stamp, so:
<div id="bck-img"></div> <script type="text/javascript"> var container = document.getelementbyid("bck-img"); var image = document.createelement("img"); image.setattribute("src", _sppagecontextinfo.webabsoluteurl+"/siteassets/article-photo.jpg?rev="+new date().gettime()); container.appendchild(image); </script>
_sppagecontextinfo.webabsoluteurl
url of current sharepoint web, whereas ?rev="+new date().gettime();
appends timestamp filename, ensuring it'll loaded server on every page load.
Comments
Post a Comment