I have a edit program that enables a user to maintain a record within a database. One of the fields in the record is an image; however, the image is actually being uploaded to a directory instead of within the database (with a pointer in the database linking to the image in the directory).
Since my program 'hard codes' the image name when the image is uploaded a caching problem occurs when the image is replaced via a new upload because it uses the same image name. After the replacement occurs the page is reloaded using a header() function in order to redisplay the record information and show that the replacement has occurred.
Anyways, what happens is that the 'old' image is displayed until the Refresh button is clicked; then the new image shows up indicating the image was replaced correctly but the browser is first showing the cached image instead of getting the new image from the server.
Now for my question....how can I force the browser to do the same thing as clicking the refresh button as I redirect / reload the page after the image replacement occurs?
I have tried echoing Javascript using history.go(0) and location.reload()...both send the browser into an infinite loop. I have also tried the following:
header ("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header ("Pragma: no-cache"):
But all to no avail. Can anybody help?
😕