RE: image cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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">)
> 
> 

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux