You are here: Fighting user's cache with an updated image « PHP « IT news, forums, messages
Fighting user's cache with an updated image

Posted by Dave on 02/02/05 17:55

PHP General,

The Situation:
I have a form on my web page which uses PHP to upload an image into
a user's directory. Because I use the uploaded image in a variety of
places in my web site, my script renames the file to conform to naming
conventions I use on the site.
Users can keep one image, and they can over write it. Just below the
form, it shows their current image. If they upload a new image, it
should display the new version.

The Problem:
Even though the file uploads correctly, and it is immediately
available, I noticed that sometimes on my own computer the image
displayed on the page with the upload form would not update. After much
experimentation, I am reasonably sure that this is because the browser's
cache is storing the image and loads the cached version and not the new
version.
If I clear out the cache after the upload, the newly uploaded image
displays. This is not confusing for me, but of course the web site users
are bound to find this troublesome.

What I've Tried So Far:
I've considered different naming conventions for files, so that the
uploaded file would have a different name, which would get around the
cache issue. But because of the existing web site structure which makes
extensive use of the file naming convention already in place, it is a
very daunting option.
Along the same lines, I considered making a temporary naming
convention for that one page, but this tested the limits of my PHP
scripting abilities. I can't claim any more skill than a newbie when it
comes to PHP.

The Question:
Is there a way I can trick the browser into getting the image file
off the server every time and not from the cache, so that it will be
clear to user's that they have successfully uploaded their image?

Any help much appreciated.

--
Dave Gutteridge
dave@tokyocomedy.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация