简体   繁体   English

Java Applet没有缓存

[英]Java Applet not caching

I'm having a problem with a Java applet I've deployed that is refusing to be cached in the jvm's "sticky" cache (or by the browser). 我遇到了一个我已部署的Java applet的问题,它拒绝缓存在jvm的“粘性”缓存(或浏览器)中。 For some reason every time a user loads the page this applet is on, the jvm re-downloads the jar file from the server which causes a long delay. 出于某种原因,每次用户加载此applet所在的页面时,jvm会从服务器重新下载jar文件,这会导致长时间的延迟。

The webpage containing the applet is being accessed via the internet, so according to Sun's Java applet documentation I'm using an <applet> tag rather than an <object> or <embed> tag. 包含applet的网页正在通过互联网访问,因此根据Sun的Java applet文档,我使用的是<applet>标签,而不是<object><embed>标签。

Any help debugging or identifying the problem would be much appreciated. 任何帮助调试或识别问题将非常感激。

Below is the full applet tag I'm using: 以下是我正在使用的完整applet标记:

<applet alt="Scanning Applet failed to load" archive="scanning.jar"
        code="scanning.scanlet.class" codebase="/java/" codetype="application/java"
        height="30" mayscript="True" name="scanlet" width="200">
    <param name="domain" value="192.168.12.23" />
    <param name="publishName" value="scan_attachment" />
    <param name="publishURL" value="http://192.168.12.23/draft/update/52" />
    <param name="curURL" value="http://192.168.12.23/draft/edit/52" />

Your browser is unable to process the Java &lt;APPLET&gt; tag needed to display this applet
<br />
One solution would be to download a better web browser like
<a href="http://www.mozilla.com/firefox">Mozilla's Firefox</a>

</applet>

I had the very same problem and found a trick that need to be applied server side. 我有同样的问题,发现需要应用服务器端的技巧。 It seems that jars aren't cached if their mime type is incorrect. 如果他们的mime类型不正确,似乎没有缓存jar。 Please check your server reply using the application/java-archive mime type. 请使用application / java-archive mime类型检查服务器回复。

Another problem I found is related to a specific jar. 我发现的另一个问题与特定的罐子有关。 My archive parameter was listing many jars, but only a few were cached. 我的归档参数列出了许多jar,但只有少数缓存。 I found that all jars upto a specific one where cached, all remaining jars weren't cached at all. 我发现所有罐子都是缓存的特定罐子,所有剩余的罐子都没有缓存。 While loading applet, I pressed "5" in its java console and found this message just after the last cached jar: cache: signed entry missing from jar . 在加载applet时,我在其java控制台中按了“5”,并在jar中找不到最后一个缓存的jar:cache:signed条目后发现此消息。 I still don't know what is wrong with this file, but I moved that jar at the end of the archive parameter list. 我仍然不知道这个文件有什么问题,但我在存档参数列表的末尾移动了那个jar。 This "fixed" the problem. 这个“修复”了这个问题。

Personally I solved the caching issues by using cache_archive and cache_version parameters docummented at http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/applet_caching.html 我个人通过使用http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/applet_caching.html中记录的 cache_archive和cache_version参数解决了缓存问题。

My cache_version is based on the actual file modification date, eg 我的cache_version基于实际的文件修改日期,例如

val archive = libs.map("/" + _.getPath).mkString (", ")
val version = libs.map(_.getUpdated / 1000 / 20 - 59281420).mkString (", ")

and to work with MSIE it looks as: 并与MSIE合作,它看起来像:

if (msie) {
  cms write <OBJECT
    classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA"
    codebase="http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab"
    width="100%" height="100%">
    ...
    <PARAM name="cache_archive" value={archive}/>
    <PARAM name="cache_version" value={version}/>
  </OBJECT>
} else {
  cms write <applet ...
    cache_archive={archive} cache_version={version}></applet>
}

This official article describes how you can change your APPLET tag to increase caching: 这篇官方文章介绍了如何更改APPLET标记以增加缓存:

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

For me I had to remove the Jar files from the Archive tag and just have it in the cache_archive parameter, and specify the versions that way it doesn't piggy back to the server for last modified date 对我来说,我不得不从Archive标签中删除Jar文件,只需将它放在cache_archive参数中,并指定版本,使其不会在最后修改日期重新回到服务器

Fixed it in firefox for me 在我的Firefox中修复了它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM