reloading images : Java Glossary

go to home page R words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all) ©1996-2009 2006-02-28 Roedy Green, Canadian Mind Products
reloading images
In your browser hitting Reload should reload a page. However, it will often get an old version of an image, if that image’s expiry time has not past. You can force it to get a new image with Shift-Reload or Control-Reload.

It would be nice to be able to do the same thing with Applets, to let you load a new version of the Applet when you are debugging, but I have found only exiting and restarting the browser works. This is because the underlying JVM is not designed to let you unload or replace class files. You can get the effect programmatically by using a new ClassLoader. Then you may have both versions of the class in RAM.

In Java programming, the URLConnection.setUseCaches( false)) can force reloading. I have not yet found a simple way to force Toolkit.getDefaultToolkit().getImage( url ) to get a fresh copy. I found that Image.flush does not work. It seems to flush only the Image cache, not other intermediate sources.

Here is a clever dodge dreamed up by Jonathan Bartlett to bypassing various caches to force a reload of an image. If you are reloading images from the web, you can randomize the URL to force reloads. So, if your url is http://www.example.com/image.gif, you could do something like http://www.example.com/image.gif?forcereload=23424, where 23424 is a randomly generated number, or generated by the current time, or something like that. Since it’s a different URL, any cache between you and the server has to reload, except at the server itself which will just ignore the extra dummy parameter.


CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/reloadimage.html J:\mindprod\jgloss\reloadimage.html
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.105]
You are visitor number 12,361.