Jump to content

How to make IE6, 7 not load images from cache


figo2476

Recommended Posts

Basically, a image will be updated over time, but it is always has the same name.

Safari and firefox understand the difference and will load the latest image. IE6,7 have

a little problem and it will load the cache image.

 

I have tried

<?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 ?>

<?php header('Pragma: no-cache'); ?>

It doesn't work in all browsers and I guess the php page flow is not as simple as from top to bottom.

It won't be desirable, since the page has many images and it should reload a particular image.

 

Not sure how to work around this....

Link to comment
Share on other sites

If nothing else works, you could put a random query string on the image path, like:

 

<?php
echo '<img src="some_image.jpg?', uniqid(), '" alt="" />';
?>

 

Will output something like

 

<img src="some_image.jpg?48353bab35680" alt="" />

 

And the same image "some_image.jpg" will always be loaded, but it will look different to the browser every time (the query string does nothing to the image).

Link to comment
Share on other sites

to ad the expiry date header you should always use a date which is set in the past the line you should use should look like this

 

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');

 

when ever i have had problems with images being cached i have added the random number to them i find it works better than trying to stop the caching of the images.  the random number syntax i use it this

 

$rand = rand (0,100);

<img src = "your_image.gif.'?'.$rand"

 

that line of code should display the image with a number appended to the end of the file so it will always have some part of the file which is different to the last it tried to display

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.