How to force a Java Applet to Load out of Cache

12,181

Solution 1

Add this inside your Applet tag: <param name="cache_option" value="no">

Speaking of Applet tags, they've been obsolete for years; consider using the object tag instead.

Solution 2

The caching of Java applets may happen at two levels: the browser and the Java plugin. Your problem seems to be with the plugin. I just found this:

http://java.sun.com/products/plugin/1.3/docs/appletcaching.html

One approach some people use is resource versioning, i.e. generate a new applet filename for each version (better if you package the applet in a jar file and rename the jar for each new version, e.g. titlescreen-1.2.23.jar). If you have a decent build tool (ant, maven) that can automate this renaming for you, both at the JAR and tag level, the better.

Solution 3

Those tags will do wonders to prevent the page from being cached. However, the applet is separate. :)

You need to configure the server to send those headers with the class file itself (if possible, investigate .htaccess support).

If that's not possible, but you have access to PHP or some server-side scripting language, you could use something like this:

<applet code="com.murderbody.prototype.TitleScreen.class?<?php echo rand(1, 10000);?>" codebase="http://people.scs.carleton.ca/~manders8/content/" width=640 height=380></applet>

Edit: Also, R. Bemrose has a good idea. Try adding this to the applet tag:

<param name="cache_option" value="no">

If that ends up being the solution, be sure to accept his answer :)

Share:
12,181
Uri
Author by

Uri

Updated on June 09, 2022

Comments

  • Uri
    Uri almost 2 years

    My friend and I are developing a little game and we want to share the development stages with our friends. So I made this little page http://people.scs.carleton.ca/~manders8/game.html

    Right now it's one .class file that we're updating. But for some reason it always loads the old version. I know there's a way to turn off java caching but my friends aren't that competent. Plus to get people to play your game it should super easy and not requiring like 5 steps with screens shots just to try it out.

    I have this is the tag:

    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Cache-Control" content="no-cache">
    

    Because I thought it might be browser related but that doesn't help.

    This is my code

    <applet code="com.murderbody.prototype.TitleScreen.class" codebase="http://people.scs.carleton.ca/~manders8/content/" width=640 height=380></applet>
    

    Changed from applet to:

    <object type="application/x-java-applet;version=1.5" width="640" height="380">
         <param name="codebase" value="http://people.scs.carleton.ca/~manders8/content/">
         <param name="code" value="com.murderbody.prototype.TitleScreen.class">
         <param name="cache_option" value="no">
    </object>