Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- problem in refresh
July 1, 2006, 4:12 pm
rate this thread
I have this question which confuse me! so please help me
Is there a difference between clicking on the refresh button in the
browser and writing this command: "window.location.reload()"
(in the meaning of loading images on a page)
The problem that I'm facing is as following:
my page uses an image to display, I wrote a code in php to change some
pixels of that image and save it with the same name, now I need to
redownload this image again in my page so I wrote the statment
"window.location.reload()" but it surprised me that the result dosen't
appear unless I clicked mannually on the "refresh" button.
It seems that the old image is preloaded in cache or such thing? and
it's reloading again and again?
I tried to use the meta tag "no-cache" but with no good!
Re: problem in refresh
Stop the caching by adding a random number after the image e.g.
where 'randomnumber' changes each time.
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Re: problem in refresh
Could be. At the HTTP level the relevant difference is between a
conditional and an unconditional GET. What a browser's Refresh
function does and what window.location.reload() does depends on the
browser and its implementation of the scripting language, neither of
which is on-topic here. I would guess window.location.reload(true)
would generally produce an unconditional GET.
Cache directives in METAs, if they're taken into account at all,
affect the document itself, not any images (or other resources)
referred to in that document. You would normally specify cache
directives for images in their own HTTP response headers.
If you have an image which changes either regularly or frequently,
and it remains conceptually the same image, you would keep it on a
tight reign, that is, specify short expiration times. That way, when
it does change, browsers re-request it rather than pull it from caches.
If, on the other hand, it is conceptually a different image, I would
rename it (you would then have to keep the document that references the
image on a tight reign).
Mark Nottingham's tutorialish page is the recommended reading.