java - JavaFX WebView / WebEngine Cache external JavaScript -


situation: have simple html page have normal script tag this

<script src="main.js"></script> 

after load html , update main.js , , make reload (throught ui button).

the problem new js not taken , must close application , open again.

what did try: -not using webengine.reload() , webengine.load() -making new broswer every time reload occurs. -making new stage new broswer -setting nodes caching off -in html following code

<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="expires" content="0" /> 

-inetaddresscachepolicy:

inetaddresscachepolicy.setnegativeifnotset(inetaddresscachepolicy.never); 

-vm options: -dnetworkaddress.cache.ttl=0.

the question there way delete cache or enforce webview reload resources other appending number js filename every time update it?

note:i use netbeans 7.3 last java (update 22)

i had similar issue when working user edited css files. goal of ui allow user edit external .css files loaded given external .html file , see changes in real-time in webengine.

i unable find reference cache clear or way force webengine re-load resources. did come turned out performing solution.

what ended doing load contents of external html file memory , replace < link > tags refer associated external .css files, < style > in-line css tags contain contents of .css files. used

webengine.loadcontent(editedhtml);  

passing newly editedhtml. technique altered load external js files in-line < script > tags.

this technique worked me because of files loading , editing local. load contents memory , save references them on application start up. if trying add js files webpage retrieved server http request may more difficult include technique application, though don't think impossible.

the specific implementation dependent on overall structure of application sudo code this:

  1. load html file's contents.
  2. parse contents html document.*
  3. for each css < link > tag
    1. load associated css file's contents
    2. replace link tag < style > tag who's contents loaded css file's contents
  4. call webengine.loadcontent(editedhtml)

*for parsing contents html document, there many useful , easy use libraries utilized. this question place of used. use jsoup , find simple, powerful, , effective , recommend @ least look/try out before choosing go different one.

this may require re-structuring of application, technique far best solution came with. let me know if have questions/concerns , try answer/address them experience technique.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -