7

I'm developping a mobile app using Cordova (3.4). My core application files are embedded in my app archive (.apk or .ipa), and some files (js/html/css) must be retrieved from my server. So if I want my application usable offline I need to use appcache for these files.

A sample of my appcache.manifest :

CACHE MANIFEST
# version 7


NETWORK:
*
http://*
https://*

CACHE:
# Message module
http://my.server.ip/module/routes.json
http://my.server.ip/module/css/style.css
http://my.server.ip/module/js/controller.js
http://my.server.ip/module/js/service.js
...

My index.html (embedded into my app) :

<!DOCTYPE html>
<html lang="en" xmlns:ng="http://angularjs.org" id="ng-app" ng-app="app" 
                          manifest="http://my.server.ip/tmp_appcache.manifest">
...
<body>
<script>
    document.addEventListener("deviceready", function(e) {
        var appCache = window.applicationCache;

        alert('device ready');

        console.log('appCache', appCache);
        // Fired after the first cache of the manifest.
        appCache.addEventListener('cached', function(event) {
            console.log(event);
            alert('Appcache OK');
        }, false);

        appCache.addEventListener('UpdateReady', function(event) {
            console.log(event);
            alert('Appcache Reloaded');
        }, false);


        appCache.addEventListener('error', function(event) {
            console.log(event);
            alert('Appcache ERROR');
        }, false);

        appCache.addEventListener('checking', function(event) {
            console.log(event);
            alert('Appcache CHECKING');
        }, false);

        appCache.addEventListener('downloading', function(event) {
            console.log(event);
            alert('Appcache DOWNLOADING');
        }, false);

        appCache.addEventListener('noupdate', function(event) {
            console.log(event);
            alert('Appcache NOUPDATE');
        }, false);

        appCache.addEventListener('obsolete', function(event) {
            console.log(event);
            alert('Appcache OBSOLETE');
        }, false);
    }, false);
</body>
</html>

My problem is, when I launch my pp (on Android AND iOS), I didn't see any of my alert (except the "device ready"), and no file is cached.

If I open the url of my webapp in the device browser I actually see my alert.

Is there an additional configuration to do in Phonegap to allow appcache ?

I've seen some article about enabling appcache in Android, but it seems to be for older version of cordova, furthermore it doesn't work for me and if it's the origin of my problem, appcache should work on iOS.

Any idea would be helpful. Thanks

Tako
  • 661
  • 12
  • 34
  • Been looking for an answer to the same question for a couple of hours and havent found a clear (and working) way of using html5 cache manifest so far... – Zwik May 13 '14 at 16:48
  • 1
    I've created an [issue on Cordova JIRA](https://issues.apache.org/jira/browse/CB-6704). – Tako May 16 '14 at 14:30
  • Another [JIRA](https://issues.apache.org/jira/browse/CB-6713) concerning this problem – Tako May 22 '14 at 08:32
  • Maybe this post can help you http://artem.savelev.com/2012/08/phonegap-cordova-appcache/ – Kim T Jan 07 '15 at 16:39

2 Answers2

1

AppCache is not supported in Cordova 3.4 and up to 4.0 and no plans for support that standard in the near future (as of 17/Apr/2015).

codevision
  • 5,165
  • 38
  • 50
-1

Basically you dont require app cache. Check the below link for more clarity.

https://www.raymondcamden.com/2015/02/26/reminder-you-dont-need-appcache-for-phonegapcordova

Easwaramoorthy Kanagaraj
  • 3,925
  • 8
  • 36
  • 62
  • You didn't understand my problem, as I said **My core application files are embedded in my app archive (.apk or .ipa), and some files (js/html/css) must be retrieved from my server.** So this article isn't relevant – Tako Dec 28 '16 at 14:37
  • Ok I got it. I am not sure about your exact use case, but as a best practice please try to keep the files in your app bundle in case if you want those to be used available offline. – Easwaramoorthy Kanagaraj Dec 30 '16 at 11:31