How to clear the Cordoba web view cache on Windows Phone 8?

I am developing a Cordova 2.9.0 application for Windows Phone 8. The application in question uses external content to a large extent, using JS and HTML content that comes from another source. Everything works fine, but the browser component is heavily cached.

The only way I discovered to clear the caches is to uninstall - install the application again to take effect. The disadvantage of this is that my localStorage also clears, slowing my loops.

I assume that the cache can be cleared by writing additional C # to the Cordova template they serve , which I use by the way.

+4
source share
2 answers

So, although it was not so important, I came across a working answer. The WebBrowser class has a suitable method to call: ClearInternetCacheAsync .

Since it CordovaBrowserinherits from WebBrowser, it is just a matter of adding one line to MainPage.xaml.cswhere the C # init of the start page occurs:

namespace FooBarApp
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            this.CordovaView.Loaded += CordovaView_Loaded;
            // blammo!
            this.CordovaView.CordovaBrowser.ClearInternetCacheAsync();
        }
+1
source
  • Phone cookie file plugin can be found HERE

  • A simple, easy jQuery plugin for reading, writing and deleting cookiescan be found HERE

I hope this solves your problem. Thank!!

0
source

Source: https://habr.com/ru/post/1535711/


All Articles