I have an image gallery where too many images are saved and displayed on a single page with update option with every image. When I upload a fresh image, it works fine. But when I change an image by uploading a new image file, it works fine on localhost (xampp) but not working on cpanel server and digital ocean server (this site is hosted on both platforms separately).
The image file changed on storage where it is uploaded and can be viewed on other browsers but current browser shows the old image instead of new uploaded image even after refreshing using Ctrl+Shift+R
.
I have to remove complete browser cache data to see the new image on both servers (but not on localhost).
I have already tried:
- https://stackoverflow.com/a/32002636/4539729
- https://stackoverflow.com/a/10740545/4539729
- https://stackoverflow.com/a/28477116/4539729
$this->output->delete_cache();
but of no use. Is there any other solution to remove old image file from browser cache on uploading a new file?
Advertisement
Answer
Dear append update time with image url like given under
example.com/image/image.img.jpg?20-02-2021 00:01:03
When you upload image save update time then append it with image url