Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 27th, 2003, 11:51 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 5 Times in 5 Posts
Default image cache problem in Internet Explorer

I have a very simple problem here that may or may not be solvable using PHP.

I recently did some redesigning on this image submission thing that I've got to make it completely object oriented.

Well that's not really the problem I have a new set-up that works beautifully. The problem appears to be with Interent Explorer, for some reason it won't cache an updated image... it continues to display the cache'd image even after its been changed on the server. Well I suppose its not really being changed on the server, cause it outputs from a database via a PHP script.

I had to get into the 'internet options' menu and turn off the cache all together in order to get the browser to ignore the cache'd copy. Which isn't really the best solution.

I am curious to know if there are headers that I could output, like a time that the file was created/modified, or something to that effect that will work with Internet Explorer's cache process.

Or something perhaps that I could do with JavaScript to force the browser to download an image every time without defaulting to the cache'd copy.. which I would consider as a last resort.

: )
Rich


:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #2 (permalink)  
Old August 28th, 2003, 12:54 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, that sucks! The problem with looking for a solution that sends headers with an image is that IE won't request an image from the server if the same image is stored in the cache and is thought to be up-to-date.

This suggests that the only solution is a horribly inefficient one -- ensuring that IE download every changeable image, EVERY time.

But if that were really true, how would IE know that the image ever changed? I mean, take this simple test. Save an image on your server. Browse to it in IE. Overwrite that image with a different image (using the same filename). Refresh the browser. Bingo -- the new image displays.

There's got to be a tip-off going on. Clearly there ought to be a better way!

I suppose your best bet is to get a network traffic monitor (port sniffer, whatever) running on your machine, and look at the actual HTTP response from the server when making requests of actual images. Perhaps IE requests the images and decides whether or not to sever the download connection based on the data it gets in the headers...


If this is all too much work, you can just use the "no-cache" header for the easy way out.

  http://www.w3.org/Protocols/rfc2616/...4.html#sec14.9


good luck, and let us know how it goes!


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #3 (permalink)  
Old October 6th, 2003, 02:02 PM
Authorized User
 
Join Date: Jun 2003
Location: San Jose, CA, USA.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well this will force the NOCACHE on this page, but you still get the same issue as turning cache off. But this may help since it's only on one page.

<HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

This belongs in the <HEAD> </HEAD> tag.

----------
~cmiller
Reply With Quote
  #4 (permalink)  
Old October 12th, 2003, 04:55 PM
Authorized User
 
Join Date: Aug 2003
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

include these lines in an always "required first" file (an "ini.php" file) :

header("Expires: Mon, 14 Jul 1789 12:30:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0

this should be ok with most of the browsers unless specifically configured on the client-side (which doesn't happen)


php/java developer
NTIC engineer
Reply With Quote
  #5 (permalink)  
Old October 13th, 2003, 01:20 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Thanks Bruce,
This fits the bill and appears to give me some flexibility.

It's very much appreciated.

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #6 (permalink)  
Old October 14th, 2003, 06:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is another brutal hack, which is useful if you are simply doing an image upload on an Admin (i.e. backend) interface and simply want to show the site admins that the new image has, indeed, uploaded... Append an arbitrary new "querystring" to the tail end of the image's URL, i.e. "randomvariable = some value that will always be different, like what is returned from time();".

Because the URL has 'changed', IE will make a fresh request.

HTH
Dan

Quote:
quote:Originally posted by quesadilla5
 Thanks Bruce,
This fits the bill and appears to give me some flexibility.

It's very much appreciated.

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::

Reply With Quote
  #7 (permalink)  
Old June 20th, 2004, 06:50 PM
Registered User
 
Join Date: Jun 2004
Location: , , United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well none of these work for me i'm sorry to say. The problem appears to lie with IE though as when i updated my php page images they appear instantly in Opera. Updated images on this php will only appear if i force a refresh of the page which is crazy as the page had already reloaded once after the form was submit to upload the new image, so refreshing the same page twice seems like madness just to get IE working as it should do!

Any more ideas of how to prevent IE using old images in a dymanic page?

I can keep the

?><META HTTP-EQUIV="Refresh" Content="0; URL=<?PHPSELF?>"><?

in my page to get it working, but this is a poor workaround and i'm not going to rest till i've found the solution to this very annoying problem (bug!) ;)
Reply With Quote
  #8 (permalink)  
Old June 20th, 2004, 06:54 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Did you try clearing the IE cache before applying the header alterations suggested here? Are your images output by PHP or just included in a PHP page?

IE sucks! Get Mozilla ;)!

Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
Reply With Quote
  #9 (permalink)  
Old June 20th, 2004, 08:18 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by richard.york
 IE sucks! Get Mozilla ;)!
Not everyone uses Mozilla though. It may be better, but most people still use IE for some reason :-)

Snib

<><
Reply With Quote
  #10 (permalink)  
Old June 21st, 2004, 04:14 AM
Registered User
 
Join Date: Jun 2004
Location: , , United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Yes i cleared the cache, the image url is output by php which is pretty standard, its not outputting a blob from a MySQL db or anything like that.

Although i earlier mentioned the page worked fine in Opera, this too isn't working 100% now for some reason. When i upload an image it moves the image to a structured directory and also creates a thumbnail of that image. Once the upload has been submitted either the thumbnail or both the image and the thumbnail display the old image but the dimensions / size of the image change to that of the new if that makes sense?...

Personally i'm quite happy using IE as i've not had an issue with it before and i always think it best to design for the populous who are going to be using it too.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet Explorer cannot open the internet site cathiec ASP.NET 2.0 Basics 1 October 22nd, 2005 01:30 PM
Internet Explorer JelfMaria VB How-To 10 April 27th, 2005 03:58 PM
PropertyGrid - Internet Explorer hosting problem dhwanilshah General .NET 1 March 18th, 2005 02:20 AM
Problem in running applets in Internet Explorer sharadagarwal BOOK: Beginning Java 2 1 June 12th, 2004 08:13 AM
internet explorer issue ak Classic ASP Basics 2 September 29th, 2003 04:00 AM



All times are GMT -4. The time now is 12:03 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.