SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to stop image caching?

    I've just added this question as a posting to another thread, but what the hell, no harm in repeating it as a new thread topic...

    I want to make sure that my browser does NOT cache web page images. I'm using a form to upload images to the web server, but (in the case where I'm replacing an old image with a new image), I don't see the new image displayed until after I click refresh/reload. Does anyone know of a cross-browser solution (almost certainly involving meta tags) which will stop browsers caching images?

    I hoped that the use of these tags:

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">

    ...as recommended here:

    http://htmlgoodies.earthweb.com/beyond/nocache.html

    ...would do the trick, but no such luck.

    Thanks for any help.

  2. #2
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, in my frustration to find an answer, I worked it out myself using a bit of PHP:

    The answer is to point your img tag to a script which itself outputs the image:

    <img src='jpegviewer.htm?filename=$DOCUMENT_ROOT/images/$filename'>

    ... and the complete script called 'jpegviewer' is:

    <?
    Header("Content-type: image/jpeg");
    $fp=fopen("$filename","r");
    fpassthru($fp);
    ?>

    Hope that helps someone else.

  3. #3
    SitePoint Member
    Join Date
    Jun 2001
    Location
    philly
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think the expires code needs to be in the gmt format like this:
    <meta http-equiv="Expires" CONTENT="Fri, 13 Aug 1978 12:34:56 GMT">
    and make sure the date is b efore the current date.

  4. #4
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your comments.

    I'd previously tried what you suggested, but it still had no impact on the non-caching of images. So far, only the solution I posted myself has forced the images to load every time.
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •