Forum Discussion
Replacing cached images in SharePoint Online
Hi, I have a folder full of images that I am using in various instances of the Editorial Card web part.
Due to a branding change I now have new versions of these files with some changes to colour scheme.
I have uploaded all the new files and overwritten the existing ones. However, I can still only see the old version of the files due to caching at the site level. Even if I delete one of the files, it still appears in cached form in the web part.
Is there a way to force the site to re-cache? Or even disable caching altogether?
This post (https://techcommunity.microsoft.com/discussions/sharepoint_general/caching-of-images-on-sharepoint-online-pages/3758651) suggests
Disable caching for the image file: You can configure your SharePoint site to disable caching for the image file. To do this, go to the site settings, select "Site collection features", and then activate the "Output Cache" feature. This will disable caching for the entire site. Alternatively, you can use the "Cache-Control" HTTP header to control caching for individual files.
However, no such setting exists in the current version of SharePoint Online. I am happy to use PowerShell if that is the only way to manipulate the setting.
Failing that, how long does it take for the cache to update naturally?
2 Replies
- CloseebCopper Contributor
In SharePoint, upload a new image with the same name and extension to overwrite the original file, and select Overwrite existing files.You can also use PowerShell to force the replacement:
Set-PnPFile -Path Document Library/Image.jpg -NewPath New Image.jpg -Overwrite - PankajBadoniIron Contributor
If you're not using a CDN, you can try the following options to resolve image caching issues:
- Perform a hard refresh of the page by pressing CTRL + F5.
- Clear your browser cache to remove any outdated image files.
- Use a versioned URL by appending a query string to the image link, such as ?v=2, to force the browser to load the latest version.