I'm trying to use app cache to approve the performance.
I have been guided in various sites. (ex. http://xguru.net/621 ... )
make cache.man file, set mime-type as text/cache-manifest.
Problem is...
it works well at the Google chrome browser, but does not work in my android phone.
I tested at ICS and Gingerbread.
This is manifest file .
CACHE MANIFEST
# manifest version v0.1
CACHE:
./programs.png
./video.png
NETWORK:
*
and then, I set my webview like this.
getSettings().setAppCacheEnabled(true);
getSettings().setDomStorageEnabled(true);
getSettings().setPluginsEnabled(true);
getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
(I changed the cacheMode to LOAD_NORMAL, NO_CACHE, but it's not different.)
To see the cache state, I use this site. http://jonathanstark.com/blog/2009/09/27/debugging-html-5-offline-application-cache/
var cacheStatusValues = [];
cacheStatusValues[0] = 'uncached';
cacheStatusValues[1] = 'idle';
cacheStatusValues[2] = 'checking';
cacheStatusValues[3] = 'downloading';
cacheStatusValues[4] = 'updateready';
cacheStatusValues[5] = 'obsolete';
var cache = window.applicationCache;
cache.addEventListener('cached', logEvent, false);
cache.addEventListener('checking', logEvent, false);
cache.addEventListener('downloading', logEvent, false);
cache.addEventListener('error', logEvent, false);
cache.addEventListener('noupdate', logEvent, false);
cache.addEventListener('obsolete', logEvent, false);
cache.addEventListener('progress', logEvent, false);
cache.addEventListener('updateready', logEvent, false);
function logEvent(e) {
var online, status, type, message;
online = (navigator.onLine) ? 'yes' : 'no';
status = cacheStatusValues[cache.status];
type = e.type;
message = 'online: ' + online;
message+= ', event: ' + type;
message+= ', status: ' + status;
if (type == 'error' && navigator.onLine) {
message+= ' (prolly a syntax error in manifest)';
}
console.log(message);
}
window.applicationCache.addEventListener(
'updateready',
function(){
window.applicationCache.swapCache();
console.log('swap cache has been called');
},
false
);
Lastly, This is the log I see on my android phone.
[cache Resource] app cache support!
[cache Resource] DOWNLOADING
[cache Resource] event online: yes, event: checking, status: uncached
[cache Resource] event online: yes, event: downloading, status: uncached
[cache Resource] event online: yes, event: progress, status: uncached
[cache Resource] event online: yes, event: progress, status: uncached
[cache Resource] event online: yes, event: error, status: uncached (prolly a syntax error in manifest)
Images are downloaded but we get the error at last line. So it is always in a uncached.
I guess the problem is on the webview setting or android application. But i cannot handle it.
give me a tip to use app cache.. plz...