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

查看:23
本文介绍了如何清除 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天全站免登陆