title: JavaFx WebView cache
body: <p>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.</p>
  
  <p>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. "</p>
  
  <p>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.</p>
  
  <p>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. "</p>
  
  <p>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 handling some web sites, notably Outlook's email.</p>
  
  <p>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):<br>
          // Given that WebKit has its own cache, do not use<br>
          // any URLConnection caches, even if someone installs them.<br>
          // As a side effect, this fixes the problem of WebPane not<br>
          // working well with the plug-in cache, which was one of<br>
          // the causes for RT-11880.  </p>
  
  <p>So can somebody out there please give me a heads up on what is really going on?</p>
  
  <ul>
  <li>Oracle documentation says WebKit has an in-memory cache which can be overriden by ResponseCache, this is not the case.</li>
  <li>JDK-8014501 states the problem, but has been flagged "not an issue". Why is it not an issue?</li>
  <li>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.</li>
  </ul>
  
  <p>Thanks in advance for any feedback,</p>