How do I clear the cache of Cordova Web View on Wi

2019-02-24 05:25发布

I'm developing a Cordova 2.9.0 app for Windows Phone 8. The app in question utilises external content heavily, using the JS and HTML content that's being served from another source. It all works fine, but the browser component caches heavily.

The only way I have discovered to clear caches is to uninstall-install the app again to take effect. The downside to this is that my localStorage also clears, slowing down my cycles.

I presume the cache can be cleared by writing extra C# into the Cordova template they serve, which I use by the way.

2条回答
劳资没心,怎么记你
2楼-- · 2019-02-24 06:04

So while it was not that critical, I did stumble to a working answer. The WebBrowser class does have a suitable method to call: ClearInternetCacheAsync.

Since CordovaBrowser inherits from WebBrowser, it's just a matter of adding one line to MainPage.xaml.cs where the C# init of the start page happens:

namespace FooBarApp
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            this.CordovaView.Loaded += CordovaView_Loaded;
            // blammo!
            this.CordovaView.CordovaBrowser.ClearInternetCacheAsync();
        }
查看更多
男人必须洒脱
3楼-- · 2019-02-24 06:26
  • Phonegap Cookies Plugin can be found HERE

  • A simple, lightweight jQuery plugin for reading, writing and deleting cookies can be found HERE

I hope it will resolve your problem. Thanks!!

查看更多
登录 后发表回答