简体   繁体   English

如何在Java Applet中动态清除JRE缓存

[英]How I can clear JRE cache dynamicly in java applet

Here is code: 这是代码:

<applet code="ATest.class" archive="ATest.class?v=200406181300">
</applet>

I want to clear existing cache and load the new one when it loads 1st time.How can i do in java applet? 我想清除现有缓存并在第一次加载时加载新的缓存。如何在Java Applet中进行操作?

I tested it in Firefox 0.9 and it loaded and ran the class. 我在Firefox 0.9中对其进行了测试,并加载并运行了该类。 The idea here is that when you change the class, you change the [v]ersion in the ARCHIVE attribute. 这里的想法是,当您更改类时,将更改ARCHIVE属性中的[v] ersion。 That should force the browser to get a new copy of the class file, since the "archive" is now at a different URI, and since the "archive" is the .class file, it might work (unless the user agent disregards ARCHIVEs that are classes, which is entirely possible) 这将迫使浏览器获得类文件的新副本,因为“存档”现在位于不同的URI上,并且由于“存档”是.class文件,因此它可能会起作用(除非用户代理忽略ARCHIVEs是类,这完全有可能)

I don't think the applet can so this. 我认为小程序无法做到这一点。

But I don't think it needs to either. 但是我也不需要。 If the changing the v parameter to a different value isn't sufficient to get the browser to request a new copy of the class, then put it into a JAR file and arrange that the JAR file's name changes each time you want to deploy a fresh version. 如果将v参数更改为其他值不足以使浏览器请求该类的新副本,则将其放入JAR文件中,并在每次要部署新的JAR文件时更改JAR文件的名称。版。


I should note that forcing the browser to download a fresh copy of a class if it hasn't changed is a bad idea. 我应该注意,如果浏览器没有更改,则强制浏览器下载该类的新副本是一个坏主意。 It won't achieve anything useful. 它不会实现任何有用的功能。 On the contrary, it will waste server and network resources, and it will make the page load slower. 相反,这将浪费服务器和网络资源,并使页面加载速度变慢。

First, read your question: Why would one update an Applet, "when it loads 1st time"? 首先,阅读您的问题:为什么要在“第一次加载Applet”时更新Applet? If you mean the second time, when the plugin tries to load it from its own cache, than just use a new codebase, maybe a new one for every visit/or. 如果您的意思是第二次,当插件尝试从其自己的缓存中加载它时,不只是使用一个新的代码库,也许每次访问/或使用一个新的代码库。

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

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