Java 1.7 小程序 CacheEntry 阻止动态更新 [英] Java 1.7 applet CacheEntry preventing dynamic updates

查看:21
本文介绍了Java 1.7 小程序 CacheEntry 阻止动态更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 Java 1.6 小程序迁移到 Java 1.7.我们的一个小程序会定期访问 URL 以检索动态状态值:

I am migrating Java 1.6 applets to Java 1.7. One of our applets periodically hits an URL to retrieve a dynamic status value:

https://host/myapp/path/to/status

然后根据最新的状态值更新.升级到 Java 1.7 后,我的客户端没有检索到最新的状态值.我在 Java 控制台中看到这样的条目:

And then it updates according to the latest status value. Since upgrading to Java 1.7, my client does not retrieve the latest status value. I see entries like this in the Java console:

CacheEntry[https://host/myapp/path/to/status]: updateAvailable=true,lastModified=Wed Dec 31 17:00:00 MST 1969,length=82

看起来客户端对该 URL 有一些缓存值,实际上并没有从服务器检索最新的动态值.

It looks like the client has some cached value for that URL and isn't actually retrieving the latest dynamic value from the server.

这作为 1.6 小程序运行良好,并且作为 1.7 独立 Java 应用程序也运行良好.作为 1.7 小程序运行时,如何禁用或绕过此缓存行为?

This worked fine as a 1.6 applet, and it also works fine as a 1.7 standalone Java application. How can I disable or bypass this caching behavior when running as a 1.7 applet?

推荐答案

我已经通过在服务器响应中使用以下 HTTP 标头解决了这个问题:

I've resolved this problem by using the following HTTP header in the server response:

Cache-Control: no-cache, no-store, no-transform

现在我的 Java 1.7 小程序每次都从服务器获取数据.显然,Oracle 在 Java 1.7 中改变了小程序响应这些标头的方式.以前(当我们使用 Java 1.6 小程序时),我们有以下标题:

Now my Java 1.7 applet fetches the data from the server every time. Apparently Oracle changed how applets respond to these headers in Java 1.7. Previously (when we were using Java 1.6 applets), we had the following header:

Cache-Control: no-cache

这在 Java 1.6 中有效,但在 1.7 中无效.

and that worked in Java 1.6 but not in 1.7.

这篇关于Java 1.7 小程序 CacheEntry 阻止动态更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆