On Mon, 20 Jan 2003, Phil Powell wrote:

> I am using the following header() functions to force view.php to not cache:
>
> header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
> header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
> header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
> header("Cache-Control: post-check=0, pre-check=0", false);
> header("Pragma: no-cache");                          // HTTP/1.0

view.php will never be cached ...

> However, when a user reuploads a file in manage.php, it does a form post
> onto manage.php and reuploads the file (which I verified works).
> However, when redirected via header() to view.php, they still see their
> OLD image file, NOT the new one!  Unless I manually refresh the page,
> they never see it, until they manually refresh the page, then the new
> image file appears!

but you failed to address the caching of images in any of your code or
setup.  The cache headers on the view.php script have /no/ affect on
anything but view.php.  You're fighting the communication betweneen the
browser and the web server, so configure one or the other to play nicely.

- Disable caching in your browser.
- Configure your web server to include cache-control & expires headers on
  all pertinent image requests.  (For example, see mod_expires for Apache:
  http://httpd.apache.org/docs/mod/mod_expires.html)

In lieu of those, change the way you handle uploads.

Instead of using the exact filename of the uploaded file, rename the file
slightly, to include a timestamp or some other changing identifier each
time the file is uploaded.  For exampple, when myImage.jpg is uploaded,
save it as myImage-001.jpg the first time, myImage-002.jpg the second
time.

        g.luck,
        ~Chris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to