Jump to content

Replacing Images


MinusMyThoughts

Recommended Posts

I'm running into an issue with my image replacement feature. I can successfully upload, rename, and save an image to replace the old image, but when i view the updated page, i still see the cached image until i reload. i looked for cache clearing scripts through this forum, but the one i found didn't seem to work in IE or Firefox......is it possible to force a browser to reload? or should i try a different approach and rename my new images to something different and use a database to store the new image name?...obviously, my life will be easier if i can just force a reload. :) any ideas?love,jason

Link to comment
Share on other sites

how does that work? i figure if i understand the command, i won't need to ask again......also, i'm generating my img tag with php, so can i get the same effect using this?

$pic1 = '<img src="images/userPics/pic1.gif?anything='	   . rand(1,1000)	   . '" align="left">';

love,jason

Link to comment
Share on other sites

That method works because everytime the image is displayed, it shows up as having a different uri. Thus, when you load the page once, it might be pic1.gif?anything=42, and when you reload it'll be pic1.gif?anything=981. Because these uri are different, the browser caches them as different images, forcing a reload everytime (unless theres the odd chance that you get the same number again).

Link to comment
Share on other sites

Caching can also be avoided during a Development stage by using a Meta-tag with an already passed date. Google on "meta expires= tag" for more info, but here are two sample meta-tags which work:

<meta http-equiv="expires" content="0"> <meta http-equiv="expires" content="Tue Dec 31 23:59:59 GMT 2002">

Only one would be required.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...