Link to home
Start Free TrialLog in
Avatar of dcpetersonp
dcpetersonp

asked on

Sun Plugin Applet URLConnection doesn't use IE browser cache

I have a legacy applet that works fine under the old MS and Netscape jvms.  However, when I try to run it under the Sun plugin jvm (1.4.2_01), I see that the URLConnection doesn't use the browser cache.  It just reads the data directly into the applet bypassing checking to see if the file was already in IE's /Temporary Internet Files/Content.IE5.  Even after the read of the file, it's still not in the browser's cache.
I've confirmed this by monitoring the data coming over the wire with ethereal and monitor what files are being written/read from my computer using filemon.
I do have
urlc.setUsesCache(true);
and even tried
urlc.setDefaultUseCaches(true);
  Doesn't help and as I said, this code has been working fine for the past 4 years in the old netscape 4 and IE w/ MS JVM environments.
  Is there some other class that I should now be using with the Sun plugin to take advantage of the browser cache?
Thanks!
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is a bit out of date, but should help:

http://java.sun.com/products/plugin/1.3/docs/appletcaching.html
Avatar of dcpetersonp
dcpetersonp

ASKER

That cache is for applet jar files.  I'm talking about downloading normal media files.  I'm dowloading very large files (e.g. .jpg, .swf, .avi, etc) and I need to take advantage of the normal IE browser content cache.
Are these not contained in jar files? If you put them in jar files, not only should you get the cache control mentioned above, but in some cases, compression optimisations.
Individual files may be placed in the .jpi_cache directory
See the comment here too on URLConnection/classpath issues:

http://forum.java.sun.com/thread.jsp?thread=458347&forum=421&message=2109189
I definitely want cache controls.
The nature of my applet's functionality prevents them from being put into jar files as I want to use them in later html pages as real files outside of my applet context.  i.e. I want the browser to see them there, not just have them available to my applet.  Not only do I want the browser to see them there, I'd like the browser to see the expiration header cache controls just like it does for the old jvms.
Also, as I said above, filemon shows that no files are being written to my disk, not even to .jpi_cache.  In fact later examination of .jpi_cache/file/1.0 shows nothing there.  However, I do certainly see my applet jar file in .jpi_cache/jar/1.0
Maybe try a classpath-oriented method of loading the files, per the above link?
Yes, I've already read that java forum posting.  My apache server is definitely not setting no-cache pragmas.  As I said, this works perfectly fine with legacy jvms.  You may also want to read this java forum posting:

http://forum.java.sun.com/thread.jsp?forum=30&thread=348986&start=0&range=15#2164058
classpath loading mechanism?  Yes, I've read that posting before, but I don't understand what they mean by classpath loading mechanism.  However, I think that point may be moot (although for my own edification, I wouldn't mind understanding what they're suggesting) because I need the files to be seen by the browser outside of my applet context.  The primary purpose of my applet is to pre-cache files for later usage in normal browser context.
>>I wouldn't mind understanding what they're suggesting

I assume something like

URL myMediaUrl = getResource("/media/x.avi");

or

InputStream in = getResourceAsStream("/media/x.avi");
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DO you have a link to the RFE so I can vote for it?  
Changing the way URLConnection has worked for the last 10 years w/o allowing for backward compatibility really stinks in my opinion.
So as far as you know, there isn't any mechanism for me to download a file and have it available for non-applet contexts?  No way to get it into the browser's cache?  I can't think of one.  I've tried to think of a way to pass it to javascript, but I can't think of how that would even work.
Last I checked the browser cache is only consulted for jar and class files. So the only workaround I know of is to rename your files extensions which doesn't help with sharing cached files with browser.

There are plans to check browser cache for all files in hopper, but that also is not a lot of help to you now.
Just for my own political commentary here, Sun developed the plugin because MS was removing support for their JVM.  You'd think that SUN would take a bit more care to make sure that things worked in the same fashion.
I've added in a bit of commentary to that RFE because it just asks for the plugin to check the browser cache.  In actuality I'd like it to check it and (at least optionally) deposit into it regardless of filetype extension.
Well, my problem isn't at all solved here, but you've been a big help in at least pointing me to where to apply leverage on Sun.  What do you think is a fair point assessment here for your help?
> Sun developed the plugin because MS was removing support for their JVM.  

Not really. MS removed support for their JVM well after the plugin was developed.

> You'd think that SUN would take a bit more care to make sure that things worked in the same fashion.

Agreed, there are some areas that Sun really needs to improve.

> What do you think is a fair point assessment here for your help?

They are your points, it up to you :)
>>What do you think is a fair point assessment here for your help?
     
I certainly don't mind if objects gets the majority of the points as he's probably provided more help
Okay, I've asked the moderators to award 75 points each to you both and to leave this open for a while.  Not sure if they can do that or not.  I'm hoping for a solution out of left field that may solve this for me, but I don't think you guys should be penalized waiting around for that.  Thanks objects & CEHJ!
great, I've asked them to switch it to 125/75 split.
:-)
Hey, can I impose on you guys to ask that you vote for this RFE please?

http://forum.java.sun.com/thread.jsp?forum=30&thread=348986&start=0&range=15#2164058 
My votes are all in use sorry.

We are having a similar problem -- when using the Plugin cache_option, it does not cache like it should. Could be something wrong with cache_version, I have heard. Have you guys found a fix for this problem?
Sun acknowledges that this is a missing 'feature'.  Suggest that you cast your votes w/ Sun to have the 'feature' implemented.  Get all of your co-workers, friends, family, etc to vote. We've managed to get the votes up to 131, but still Sun isn't working on it.  Pile your votes on. ;)
http://developer.java.sun.com/developer/bugParade/bugs/4528599.html
Now it is 132. Grrr.
FYI, you have 3 votes that you can cast.  Course you may be using the other 2 for something else....
134. Didn't know you could put all three on one.
Top 25 RFEs (request for enhancement).  You can see where we're at via the link below.  Suggest that you get friends, colleagues, whoever to vote because we're not really going anywhere fast with getting a solution for this.  About our only hope is if Microsoft and Sun partner together to put SunJava bundled into windows.  If that happens, I'm sure MS will push Sun hard to fix these things and probably even assign their own engineers to fix/test that it all runs 100% on windows.
RFEs
http://bugs.sun.com/bugdatabase/top25_rfes.do
Bugs
http://bugs.sun.com/bugdatabase/top25_bugs.do