Cordova app is saving DOM loaded data using AJAX o

2019-06-08 01:49发布

问题:

My Cordova+JQM application has multiple templates (across sub-pages and multiple HTML documents) which are filled with data requested using AJAX. My issue is, my application's size increases each time I load the data in my template, doesn't matter if I have opened it before. And the app's details do not show an increase in Cache, but in Data. The cache is minimum, like a few kbs, but Data goes in MBs.

I have not enabled data-dom-cache of JQM. I even tried to call a function to empty the DOM data before leaving the template(that is from one HTML file to another) like this:

$( document ).on( "pagecontainerbeforehide", function() {
  console.log("gonna leave");    
  $("#page-container").empty();
} );

And it didn't work. In fact, I am not able to call any event while leaving (going to another HTML document).

回答1:

The problem was, whatever Cordova received via AJAX was cached into app_webview/Cache. So, I tried using the File API to delete the content, but somehow it kept on failing; gave some unknown error, so debugging that was impossible.

But this plugin did the thing: https://github.com/Sharinglabs/cordova-plugin-cache. It is compatible with Cordova 3.3.1 and above. It works with my Cordova 4.2.0 app.