By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

problem in refresh

P: n/a
Hello experts

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!

Jul 1 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Message-ID: <11**********************@v61g2000cwv.googlegroups .com> from
ma*****@hotmail.com contained the following:
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!


Stop the caching by adding a random number after the image e.g.

<img src="myimage.jpg?rand=randomnumber">

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/
Jul 1 '06 #2

P: n/a
ma*****@hotmail.com:
Is there a difference between clicking on the refresh button in the
browser and writing this command: "window.location.reload()"
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.
(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?
Sounds right.
I tried to use the meta tag "no-cache" but with no good!


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.

--
Jock

Jul 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.