Before you mark this question as a duplicate, please note that I have seen similar questions on Stack Overflow, but none of them have been able to solve the issue for me.
I have a PHP script that creates a custom directory listing here:
http://snaps.vertigofx.com/index.php
These particular folders are for storing images. I have found that I will often I will be click an image to view it, and while it is open I will upload a new image. When I navigate "back" in my browser to get the newly uploaded image, I then also have to refresh the page for it to show up in the file listing.
Is there any way, either through PHP, Javascript, or even a Firefox setting/extension, that I can force the listing to refresh when I navigate back? (Please note that I want this to be site specific, so I don't want to use a browser setting that will make this effect global)
I have tried adding this to the PHP script, as it was the accepted answer on a similar question, but it did not work:
header("Cache-Control: private, must-revalidate, max-age=0");
header("Pragma: no-cache");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // A date in the past
This works:
While the question at How to force page not to be cached in PHP? is not really a duplicate of my question (the asker on that post was referring to a single page whereas I need a solution that covers multiple pages), I was able to find a solution there. It's the cache-killer headers like I tried before but with a few more lines:
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Pragma: no-cache"); // HTTP/1.0
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
Confession: While working with this, it seems that changes to the code only seemed to reflect in the browser after actually deleting the file from the server, attempting to access it in the browser, and then uploading the new file. Simply overwriting the file didn't work for some reason. Because of this, it's very possible that my previous attempts at this may have very well been valid solutions that I just thought weren't working. I apologize for "wasting" anybody's time, and appreciate the help.