Lifetime of Applet

Does an applet get reloaded every time you restart your browser? Is there a way to have it cached by the browser until a new version is available? Thanks.
[168 byte] By [jburggraf] at [2007-9-26 3:59:23]
# 1
Actually the browser may store the applet in the cache automatically, which can cause a few problems. In general the problem is having the applet class/jar file not cached.
jsalonen at 2007-6-29 12:53:21 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 2

Does it get cached forever or only until you stop your browser? The reason I am asking is I was wondering what you would have to do to release an updated applet. I have written ActiveX controls in the past and IE allows you to specify a version # and it will download a new control if the version # is higher than the version cached locally.

jburggraf at 2007-6-29 12:53:21 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 3

It is cached *at least* until you shut down the browser or force reloading (Ctrl+F5 in IE, shift+reload in NN). Some files may be kept even longer.

I don't think there's any simple way to achieve what you are hoping to do -- there is no version number system in java applets. Because of the sandbox model applets should have *very* little access to the local file system so even caching the class files is a little suspicious.

Java web start might be an answer, if you really want one...

jsalonen at 2007-6-29 12:53:21 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 4

A simple way of achieving what you want is to specify the version number in the filename of the JAR that your Applet is distributed in:

myapplet10.jar

myapplet11.jar

You'll have to update the HTML page that delivers the Applets but that should at least beat the browser's caching policy. Just a thought.

KPSeal at 2007-6-29 12:53:21 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 5

Applet jars are cached according to how long you set their lifetime. There are tags you can set so that the browser will check for updated jars each time. I cannot remember the exact format of the Applet or Object html tag but I am sure you can do this bit of research.

The 'state' of the applet is not cached as this is what your question appears to ask. you will have to use sessions to store state.

JElliot at 2007-6-29 12:53:21 > top of Java-index,Archived Forums,New To Java Technology Archive...