NYCPHP Meetup

NYPHP.org

Fw: [PHP] Cannot show reuploaded image file on page unless manual refresh

Phil Powell soazine at erols.com
Mon Jan 20 17:08:20 EST 2003


----- Original Message -----
From: "Phil Powell" <soazine at erols.com>
To: <shiflett at php.net>
Sent: Monday, January 20, 2003 5:08 PM
Subject: Re: [PHP] Cannot show reuploaded image file on page unless manual
refresh


> Chris, that made no sense to me at all!
>
> How in the world could an HTTP-RESPONSE send back a cached .jpg file that
no
> longer exists on the server end? That's impossible, unless the entire page
> is cached.  Now, how do I ensure that view.php always gets the "fresh"
image
> every time?
>
> Phil
>
> ----- Original Message -----
> From: "Chris Shiflett" <shiflett at php.net>
> To: "Phil Powell" <soazine at erols.com>; <php-general at lists.php.net>;
> <talk at nyphp.org>
> Sent: Monday, January 20, 2003 5:03 PM
> Subject: Re: [PHP] Cannot show reuploaded image file on page unless manual
> refresh
>
>
> > --- Phil Powell <soazine at erols.com> 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");
> > > header("Last-Modified: " . gmdate("D, d M Y H:i:s") .
> > > " GMT");
> > > header("Cache-Control: no-store, no-cache,
> > > must-revalidate");
> > > header("Cache-Control: post-check=0, pre-check=0",
> > > false);
> > > header("Pragma: no-cache");
> >
> > :-)
> >
> > I think you killed it.
> >
> > > 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!
> >
> > Right.
> >
> > I think you are forgetting that the image is not really
> > part of the PHP resource. Meaning, this is the series of
> > events for a PHP script that refernces a single image
> > called bar.jpg using the <img> tag:
> >
> > 1. HTTP request sent for foo.php (Web client -> Web server)
> > 2. HTTP response sent that includes the output of foo.php
> >    (Web server -> Web client)
> > 3. Web client (browser) notices <img> tag referenced in
> >    the HTML.
> > 4. HTTP request sent for bar.jpg (Web client -> Web server)
> > 5. HTTP response sent that includes bar.jpg
> >
> > So, the headers that you are setting only matter for the
> > resource returned in step 2. Meaning, the HTML output of
> > foo.php is not cached. The image, since it is returned by
> > the Web server and not your PHP script, is cached.
> >
> > Chris
>




More information about the talk mailing list