且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java小程序永久缓存,不下载新版本?

更新时间:2023-11-19 22:25:46

遗憾的是,不同版本的 Java 插件具有不同的缓存行为.设置 Cache-Control 和 Last-Modified HTTP 标头是理想的解决方案,但它仅适用于 JRE 的最新版本.

Unfortunately, different versions of the Java Plug-In have different caching behaviors. Setting your Cache-Control and Last-Modified HTTP headers is the ideal solution, but it only works under the most recent versions of the JRE.

唯一保证有效的解决方案是在版本更改时重命名应用程序 jar(在尝试其他技巧时,例如根据文件日期添加查询字符串时,我们看到了奇怪的缓存行为).如果您有一个适当的自动化部署系统,这并不难做到.

The only solution GUARANTEED to work is to rename your application jars when their versions change (we've seen strange caching behavior when trying other tricks like adding query strings based on file dates). This isn't so difficult to do if you have a properly automated deployment system.