problem in refresh

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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!

Re: problem in refresh contained the following:

Quoted text here. Click to load it

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

Re: problem in refresh

Quoted text here. Click to load it

  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.

Quoted text here. Click to load it

  Sounds right.

Quoted text here. Click to load it

  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.


Site Timeline