PhoneGap禁用缓存 [英] PhoneGap disable caching

查看:248
本文介绍了PhoneGap禁用缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个html文件,其中我使用JavaScript从文本文件中查看表的列表。这里的问题是,每次我在平板电脑上的PhoneGap中输入页面时,它会显示我的旧内容。在我的计算机上尝试时,我必须键入 Ctrl + F5 才能获取最新内容。



如何使我的html页面更新PhoneGap中的内容?



我发现一些元标记用于禁用缓存,但对我来说不起作用。

解决方案

我建议您使用以下插件:



https://github.com/moderna/cordova-plugin-cache

  document.addEventListener('deviceready',onDeviceReady); 
function onDeviceReady()
{
var success = function(status){
alert('Message:'+ status);
}

var error = function(status){
alert('Error:'+ status);
}

window.cache.clear(success,error);
}

这将在每次启动时清除应用程序的缓存。 >

您可以在回电中注解快讯。


I've made a html file where I'm using JavaScript to view a list of table from a textfile. The issue here is that every time I enter the page in PhoneGap on my tablet, it shows me the old content. When trying it on my computer, I have to type Ctrl + F5 to get the latest content.

How can I make my html page update the content in PhoneGap?

I found some meta tags for disabling the cache, but it doesn't work for me.

解决方案

I would suggest you to use the following plugin :

https://github.com/moderna/cordova-plugin-cache

document.addEventListener('deviceready', onDeviceReady);
function onDeviceReady()
{
    var success = function(status) {
        alert('Message: ' + status);
    }

    var error = function(status) {
        alert('Error: ' + status);
    }

    window.cache.clear( success, error );
}

This will clear the cache of your application everytime you launch it.

You can comment alerts in the callbacks.

这篇关于PhoneGap禁用缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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