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
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
It looks like the client has some cached value for that URL and isn't actually retrieving the latest dynamic value from the server.
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?
Had a similar problem with a Java applet and this fixed it:
Go to Control Panel (or System Preferences) > Java > General > Settings and then uncheck the box that says "Keep temporary files on my computer".
I already solved this problem that has been happening to me as well.
I add some fake arguments at the end of the URL such as date time or what ever that change every time i call the url.
for my own solution:
I genereate a date string
and after that when i call the url i put the date sstring to the end of the url
with this solution, it'll fool java as a new url, so there's no any cache for this url, then java would always retrieve the data.
PS. it wouldn't be the best solution, but it saves me.
For me using setUseCaches(false) alone did not work. But calling both the following methods did work:
I suspect the reason is that my original url redirects to another url. The above code should work for all cases.
I'm having the same problem. I tried using
URLConnection.setUsesCaches(false)
but that does absolutely nothing.I had to add the following to an http config file for apache. Then it worked.
I've resolved this problem by using the following HTTP header in the server response:
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:
and that worked in Java 1.6 but not in 1.7.