NYCPHP Meetup

NYPHP.org

[nycphp-talk] Prevent (IE) browser cache of image

tedd tedd at sperling.com
Fri Apr 6 12:06:11 EDT 2007


At 4:10 PM +0200 4/6/07, Jakob Buchgraber wrote:
>Aaron Fischer wrote:
>>Hi there,
>>
>>I have a little app that is a pseudo-day-planner.  Users can enter 
>>appointments via a form and then I use PHP and GD to write the 
>>appointment blocks onto a calendar image.
>>
>>It works great in Safari on Mac and Firefox on PC.  However, it 
>>doesn't work with Internet Explorer on PC.  It appears that the 
>>issue is that IE is not loading a fresh version of the calendar 
>>image each time a change is made.
>>
>>How can I force IE to load a fresh version of the image, either via 
>>PHP or HTML/HTTP code?
>>
>>Thanks!
>>
>>-Aaron
>>
>>_______________________________________________
>>New York PHP Community Talk Mailing List
>>http://lists.nyphp.org/mailman/listinfo/talk
>>
>>NYPHPCon 2006 Presentations Online
>>http://www.nyphpcon.com
>>
>>Show Your Participation in New York PHP
>>http://www.nyphp.org/show_participation.php
>>
>Just add a unique string to the URL of the image
>
><img src="createImg.php?<?php echo time(); ?>" />
>
>So the URL of the string changes every time the user reloads the page
>
>Cheers,
>Jay
>

I use echo rand(), but it's the same idea.

You could also use the following as an include file.:

<?php # nocache.php
// this script prevents all caching
// expires on any past date
header ("Expires: Mon, 26 Jul 1997 05:00: GMT");
// last modified at current date and time
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
// for HTTP 1.1:
header ("Cache-Control: no-store, no-cache, must-revalidate");
header ("Cache-Control: post-check=0, pre-check=0", false);
// for HTTP 1.0
header ("Pragma: no-cache");
?>

Cheers,

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list