For Programmers: Free Programming Magazines  


Home > Archive > PHP on Windows > November 2004 > RE: [PHP-WIN] image cache









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [PHP-WIN] image cache
Mike

2004-11-24, 3:59 pm

Here's a little trick that works for me

$cur_time = time();
print "<img src='" . $file . "?" . $cur_time . "'>";

Since each time you load the page the image name will be different (since
$cur_time will always change) the browser thinks the files are always
different since the name changes - and thus you force a reload of the image.

I do this on scripts that I make changes to images in PHP and need to see
the new image after the page reloads instead of seeing the pre-processed
image.

(I also do something similar with JavaScript for webcam images to prevent
caching)

-M

> i have an image upload script that uses fixed image names...
> when i update an image, that image will be replaced at the
> server using the same name as the old image... now, my
> browser doesn't check for the new image but checkes it cache
> instead and ofcourse finds the old image... how can i fix this?
> i've allready added headers for not letting the page cache;
> (<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> <META
> HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> )
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com