如何清除Windows Phone 8上的Cordova Web View的缓存? [英] How do I clear the cache of Cordova Web View on Windows Phone 8?

查看:353
本文介绍了如何清除Windows Phone 8上的Cordova Web View的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Windows Phone 8开发一个Cordova 2.9.0应用程序。该应用程序使用从另一个来源提供的JS和HTML内容大量利用外部内容。它一切正常,但浏览器组件缓存大量。

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.

我发现清除缓存的唯一方法是卸载 - 安装应用程序再次生效。这样做的缺点是我的localStorage也清除了,减慢了我的周期。

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.

我认为缓存可以通过写入额外的C#到Cordova模板中清除他们服务,我用的方式。

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

推荐答案

所以虽然不是那么重要,我做了一个工作的答案。 WebBrowser 类有一个合适的方法来调用: ClearInternetCacheAsync

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.

由于 CordovaBrowser 继承自 WebBrowser ,只是在 MainPage.xaml.cs 中添加一行代码,其中开始页面的C#init发生:

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();
        }

这篇关于如何清除Windows Phone 8上的Cordova Web View的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆