Applet不会缓存jar文件

时间:2013-04-18 18:28:38

标签: java applet jnlp java-web-start japplet

我遇到问题,确定为什么一些重的.jar文件没有在客户端缓存。

小程序运行正常,但它懒得下载每次运行的重型jar库(特别是aws-java-sdk和xuggler)

小程序:

使用javascript

应用于HTML DOM
<applet archive="MyScreencast.jar" code="SrcApplet.class" codebase="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/" height="50" width="130">
  <param name="cache_archive" value="lib/swing-layout-1.0.4.jar, lib/slf4j-api-1.6.4.jar, lib/slf4j-jcl-1.6.4.jar, lib/xuggle-xuggler-noarch-5.4.jar, lib/aws-java-sdk-1.4.0.jar, lib/commons-codec-1.3.jar, lib/commons-logging-1.1.1.jar, lib/httpclient-4.1.1.jar, lib/httpcore-4.1.jar, lib/xuggle-xuggler-arch-x86_64-w64-mingw32.jar, lib/xuggle-xuggler-arch-x86_64-xuggle-darwin11.jar, lib/xuggle-xuggler-arch-x86_64-pc-linux-gnu.jar">
  <param name="cache_version" value="1.0, 1.4.0, 1.3, 1.1.1, 4.1.1, 4.1, 1.6.4, 5.4.0">
  <param name="jnlp_href" value="http://beta.remoting.io/screencasts/118/launch.jnlp">
  <param name="outputFileName" value="filename.mp4">
  <param name="token" value="secrettoken">
  <param name="image" value="http://djebp0fi6w5vu.cloudfront.net/assets/ajax-loader-40b35ac3503bcb1279f0851d57d2b62a.gif">
  <param name="name" value="myscreencast">
</applet>

launch.jnlp

接头:

HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/x-java-jnlp-file; charset=utf-8
Date: Thu, 18 Apr 2013 06:51:43 GMT
Etag: "0acc9670f5347a89063c1ad76ba6a931"
Status: 200 OK
X-Rack-Cache: miss
X-Request-Id: b26b35dc9b336fd42da4f2bf0403b58c
X-Runtime: 0.261893
X-Ua-Compatible: IE=Edge,chrome=1
Connection: keep-alive

响应:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp href="/screencasts/118/launch.jnlp" spec="1.0+">
  <information>
      <title>MyScreencast</title>
      <vendor>dotg</vendor>
      <homepage href="/screencasts/118/launch.html"/>
      <description>MyScreencast</description>
      <description kind="short">MyScreencast</description>
  </information>
  <update check="always"/>
  <security>
    <all-permissions/>
  </security>
  <resources>
    <j2se java-vm-args="-Djava.security.policy=http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/applet.policy" version="1.6+"/>
    <jar href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/MyScreencast.jar" main="true"/>
      <resources arch="x86_64" os="Windows">
          <nativelib href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/xuggle-xuggler-arch-x86_64-w64-mingw32.jar"/>
      </resources>
      <resources arch="x86_64" os="Mac OS X">
          <nativelib href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/xuggle-xuggler-arch-x86_64-xuggle-darwin11.jar"/>
      </resources>
      <resources arch="x86_64" os="Linux">
          <nativelib href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/xuggle-xuggler-arch-x86_64-pc-linux-gnu.jar"/>
      </resources>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/swing-layout-1.0.4.jar"/>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/slf4j-api-1.6.4.jar"/>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/slf4j-jcl-1.6.4.jar"/>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/xuggle-xuggler-noarch-5.4.jar"/>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/aws-java-sdk-1.4.0.jar"/>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/commons-codec-1.3.jar"/>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/commons-logging-1.1.1.jar"/>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/httpclient-4.1.1.jar"/>
      <jar download="lazy" href="http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/httpcore-4.1.jar"/>
  </resources>
  <applet-desc height="32" main-class="com.dotg.screencast.ScrApplet" name="MyScreencast" width="32">
    <param name="token" value="secrettoken"/>
    <param name="outputFileName" value="somefilename.mp4"/>
  </applet-desc>
</jnlp>

.jar文件

头:

$ curl -I http://s3.amazonaws.com/remoting-io-cdn/recorder/v3/lib/aws-java-sdk-1.4.0.jar
HTTP/1.1 200 OK
x-amz-id-2: +VVx4kAqF4o+aQ+TdzLLCY8aMxcaYtP739ZcttwyFXrYK3lJgG9xnZ0nErtT8+cu
x-amz-request-id: D16687EF72E5F892
Date: Thu, 18 Apr 2013 18:17:12 GMT
Cache-Control: public, max-age=31557600
Last-Modified: Thu, 18 Apr 2013 13:18:48 GMT
ETag: "f577609185df722d54e85b822dbd043c"
Accept-Ranges: bytes
Content-Type: application/x-java-archive
Content-Length: 10293926
Server: AmazonS3

为什么.jar文件没有缓存?

1 个答案:

答案 0 :(得分:0)

javaws有一些选项可以帮助您调查缓存。

特别是,运行javaws -viewer

Java Web Start:
Usage:  javaws [run-options] <jnlp-file>
        javaws [control-options]

where run-options include:
  -verbose          display additional output
  -offline          run the application in offline mode
  -system           run the application from the system cache only
  -Xnosplash        run without showing a splash screen
  -J<option>        supply option to the vm
  -wait             start java process and wait for its exit

control-options include:
  -viewer           show the cache viewer in the java control panel
  -clearcache       remove all non-installed applications from the cache
  -uninstall        remove all applications from the cache
  -uninstall <jnlp-file>                remove the application from the cache
  -import [import-options] <jnlp-file>  import the application to the cache

import-options include:
  -silent           import silently (with no user interface)
  -system           import application into the system cache
  -codebase <url>   retrieve resources from the given codebase
  -shortcut         install shortcuts as if user allowed prompt
  -association      install associations as if user allowed prompt