Cordova app is saving DOM loaded data using AJAX on Android app's Data space

我是研究僧i 提交于 2019-12-08 06:05:41

问题


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.



来源:https://stackoverflow.com/questions/27996998/cordova-app-is-saving-dom-loaded-data-using-ajax-on-android-apps-data-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!