如何强制 Java Applet 从缓存中加载

发布于 2024-10-03 17:10:18 字数 1146 浏览 1 评论 0原文

我和我的朋友正在开发一个小游戏,我们想与我们的朋友分享开发阶段。所以我做了这个小页面 http://people.scs.carleton.ca/~ manders8/game.html

现在我们正在更新一个 .class 文件。但由于某种原因它总是加载旧版本。我知道有一种方法可以关闭 java 缓存,但我的朋友没有那么能干。另外,为了让人们玩你的游戏,它应该非常简单,不需要 5 个步骤和屏幕截图来尝试一下。

我的标签是:

<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">

因为我认为它可能与浏览器相关,但这没有帮助。

这是我的代码

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

从小程序更改为:

<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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

末蓝 2024-10-10 17:10:18

将其添加到 Applet 标记中:

说到 Applet 标记,它们已经过时多年了;考虑使用 object 标记 相反。

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.

暗喜 2024-10-10 17:10:18

Java applet 的缓存可能发生在两个级别:浏览器和 Java 插件。你的问题似乎与插件有关。我刚刚发现这个:

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

有些人使用的一种方法是资源版本控制,即为每个版本生成一个新的小程序文件名(如果将小程序打包在 jar 文件中并为每个新版本重命名该 jar 会更好) ,例如 titlescreen-1.2.23.jar)。如果您有一个不错的构建工具(ant、maven)可以在 JAR 和标签级别自动为您重命名,那就更好了。

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.

随风而去 2024-10-10 17:10:18

这些标签将创造奇迹,防止页面被缓存。然而,小程序是独立的。 :)

您需要配置服务器以将这些标头与类文件本身一起发送(如果可能,请研究 .htaccess 支持)。

如果这是不可能的,但您可以访问 PHP 或某些服务器端脚本语言,您可以使用如下内容:

<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>

编辑:此外,R. Bemrose 有一个好主意。尝试将其添加到小程序标签中:

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

如果这最终成为解决方案,请务必接受他的答案:)

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文