[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    WebKit Cache
From:       John Maton <john2011uk () gmail ! com>
Date:       2015-10-17 9:44:17
Message-ID: CACH-B_8YA5Vd3TBbyMTrOvspHMmCGA2vUosC+w+_2cPvx+RFHg () mail ! gmail ! com
[Download RAW message or body]

I have been trying to implement a disc based cache for WebView but with
only partial success, I am particularly trying to cache the .js javascript
external files which slow down the loading of javascript web pages a lot.

The Oracle documentation states that:
"When working with the WebView component, you should remember that it has
the default in-memory cache.
It means that any cached content is lost once the application containing
the WebView component is closed.
However, developers can implement cache at the application level by means
of the java.net.ResponseCache class. "

but this is not the case. I implemented an in-memory cache using the
java.net.ResponseCache class but it is very rarely used by WebView - from
time to time it stores and retrieves favicon.png from the cache - no
performance gain.

I confirmed by analysing the net traffic that WebView is not caching, thus
confirming what is stated in JDK-8014501:
"While navigating with JavaFX WebView component javafx.scene.web.WebView,
it was found,
that every request retrieves all resources from the server each time even
if previous activities have just  retrieved the resources. This behaviour
was verified by capturing and analyzing the network traffic.
The performance impact is considerable. "

nothing seems to have come out of JDK-8014501, so I then wrote a cache
handler using "URL.setURLStreamHandlerFactory" to intercept all
URLConnections to the default sun handler. I had some success with this and
was able to cache .js javascript files and increase performance
significantly, but there were bugs on a few web sites, notably Outlook's
email.

On looking into the way my code was handled, I found for example that the
URLLoader code was setting setUsesCaches(false) with the following comments
in the code (at line 279 of URLLoader.java in current 1.8.0_66 code):
        // Given that WebKit has its own cache, do not use
        // any URLConnection caches, even if someone installs them.
        // As a side effect, this fixes the problem of WebPane not
        // working well with the plug-in cache, which was one of
        // the causes for RT-11880.

So can somebody out there please give me a heads up on what is really going
on?

 - Oracle documentation says WebKit has an in-memory cache which can be
overriden by ResponseCache, this is not the case.
 - JDK-8014501 states the problem, but has been flagged "not an issue". Why
is it not an issue?
 - signifant coding around "URL.setURLStreamHandlerFactory" and
"URLConnection" interception produces a functional cache with significant
performance gains, but is undone by problems deliberately introduced into
URLLoader code.

Thanks in advance for any feedback,
John Maton
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic