Connecting Tech Pros Worldwide Help | Site Map

problem in refresh

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 1st, 2006, 04:15 PM
mayla_i@hotmail.com
Guest
 
Posts: n/a
Default problem in refresh

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!


  #2  
Old July 1st, 2006, 05:35 PM
Geoff Berrow
Guest
 
Posts: n/a
Default Re: problem in refresh

Message-ID: <1151770378.578634.174390@v61g2000cwv.googlegroups .com> from
mayla_i@hotmail.com contained the following:
[color=blue]
>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![/color]

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/
  #3  
Old July 1st, 2006, 07:05 PM
John Dunlop
Guest
 
Posts: n/a
Default Re: problem in refresh

mayla_i@hotmail.com:
[color=blue]
> Is there a difference between clicking on the refresh button in the
> browser and writing this command: "window.location.reload()"[/color]

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.
[color=blue]
> (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?[/color]

Sounds right.
[color=blue]
> I tried to use the meta tag "no-cache" but with no good![/color]

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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.