Offline data cache for Cordova Mobile application











up vote
0
down vote

favorite












I have a Cordova application (Ionic3/Angular) where I wish to add offline data cache, where I would also like to prefetch some of the data, even if the user does not go to the view that would normally invoke the request for that data.



Most caching posts I find have to do with caching web assets such as the actual application files, rather than data fetched via ajax. In my case, (Cordova), I already have all these, I just need to cache the data. For the asset caching, I see toolbox mentioned a lot and being run from within a service worker.



Can toolbox be used for this? Also, does toolbox need to be used in a service worker (worried about iOS support).



If not toolbox, is there something more appropriate I can use for this?



Thanks in advance for any pointers.










share|improve this question






















  • If you are only looking to cache ajax requests, you can manually do so by storing them the localstorage (or using NativeStorage plugin). You can write a javascript class like functions that all your code calls to when doing ajax request. This class can then check whether if the request is cached or not. You would have to store a special key (the url should do) so you can find the difference between all the data you have.
    – kks21199
    Nov 5 at 3:35










  • Thanks @kks21199, I was hoping there was some library that would do some of this stuff for "free" (ie intercept, and have caching strategoies similar to toolbox)
    – peterc
    Nov 5 at 5:04















up vote
0
down vote

favorite












I have a Cordova application (Ionic3/Angular) where I wish to add offline data cache, where I would also like to prefetch some of the data, even if the user does not go to the view that would normally invoke the request for that data.



Most caching posts I find have to do with caching web assets such as the actual application files, rather than data fetched via ajax. In my case, (Cordova), I already have all these, I just need to cache the data. For the asset caching, I see toolbox mentioned a lot and being run from within a service worker.



Can toolbox be used for this? Also, does toolbox need to be used in a service worker (worried about iOS support).



If not toolbox, is there something more appropriate I can use for this?



Thanks in advance for any pointers.










share|improve this question






















  • If you are only looking to cache ajax requests, you can manually do so by storing them the localstorage (or using NativeStorage plugin). You can write a javascript class like functions that all your code calls to when doing ajax request. This class can then check whether if the request is cached or not. You would have to store a special key (the url should do) so you can find the difference between all the data you have.
    – kks21199
    Nov 5 at 3:35










  • Thanks @kks21199, I was hoping there was some library that would do some of this stuff for "free" (ie intercept, and have caching strategoies similar to toolbox)
    – peterc
    Nov 5 at 5:04













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a Cordova application (Ionic3/Angular) where I wish to add offline data cache, where I would also like to prefetch some of the data, even if the user does not go to the view that would normally invoke the request for that data.



Most caching posts I find have to do with caching web assets such as the actual application files, rather than data fetched via ajax. In my case, (Cordova), I already have all these, I just need to cache the data. For the asset caching, I see toolbox mentioned a lot and being run from within a service worker.



Can toolbox be used for this? Also, does toolbox need to be used in a service worker (worried about iOS support).



If not toolbox, is there something more appropriate I can use for this?



Thanks in advance for any pointers.










share|improve this question













I have a Cordova application (Ionic3/Angular) where I wish to add offline data cache, where I would also like to prefetch some of the data, even if the user does not go to the view that would normally invoke the request for that data.



Most caching posts I find have to do with caching web assets such as the actual application files, rather than data fetched via ajax. In my case, (Cordova), I already have all these, I just need to cache the data. For the asset caching, I see toolbox mentioned a lot and being run from within a service worker.



Can toolbox be used for this? Also, does toolbox need to be used in a service worker (worried about iOS support).



If not toolbox, is there something more appropriate I can use for this?



Thanks in advance for any pointers.







cordova ionic-framework progressive-web-apps offline-caching






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 5 at 3:31









peterc

1,3522550




1,3522550












  • If you are only looking to cache ajax requests, you can manually do so by storing them the localstorage (or using NativeStorage plugin). You can write a javascript class like functions that all your code calls to when doing ajax request. This class can then check whether if the request is cached or not. You would have to store a special key (the url should do) so you can find the difference between all the data you have.
    – kks21199
    Nov 5 at 3:35










  • Thanks @kks21199, I was hoping there was some library that would do some of this stuff for "free" (ie intercept, and have caching strategoies similar to toolbox)
    – peterc
    Nov 5 at 5:04


















  • If you are only looking to cache ajax requests, you can manually do so by storing them the localstorage (or using NativeStorage plugin). You can write a javascript class like functions that all your code calls to when doing ajax request. This class can then check whether if the request is cached or not. You would have to store a special key (the url should do) so you can find the difference between all the data you have.
    – kks21199
    Nov 5 at 3:35










  • Thanks @kks21199, I was hoping there was some library that would do some of this stuff for "free" (ie intercept, and have caching strategoies similar to toolbox)
    – peterc
    Nov 5 at 5:04
















If you are only looking to cache ajax requests, you can manually do so by storing them the localstorage (or using NativeStorage plugin). You can write a javascript class like functions that all your code calls to when doing ajax request. This class can then check whether if the request is cached or not. You would have to store a special key (the url should do) so you can find the difference between all the data you have.
– kks21199
Nov 5 at 3:35




If you are only looking to cache ajax requests, you can manually do so by storing them the localstorage (or using NativeStorage plugin). You can write a javascript class like functions that all your code calls to when doing ajax request. This class can then check whether if the request is cached or not. You would have to store a special key (the url should do) so you can find the difference between all the data you have.
– kks21199
Nov 5 at 3:35












Thanks @kks21199, I was hoping there was some library that would do some of this stuff for "free" (ie intercept, and have caching strategoies similar to toolbox)
– peterc
Nov 5 at 5:04




Thanks @kks21199, I was hoping there was some library that would do some of this stuff for "free" (ie intercept, and have caching strategoies similar to toolbox)
– peterc
Nov 5 at 5:04












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Besides the method mentioned by @kks21199 , Angular does provide a way to cache http requests. Read here for more details.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147952%2foffline-data-cache-for-cordova-mobile-application%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Besides the method mentioned by @kks21199 , Angular does provide a way to cache http requests. Read here for more details.






    share|improve this answer

























      up vote
      0
      down vote













      Besides the method mentioned by @kks21199 , Angular does provide a way to cache http requests. Read here for more details.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Besides the method mentioned by @kks21199 , Angular does provide a way to cache http requests. Read here for more details.






        share|improve this answer












        Besides the method mentioned by @kks21199 , Angular does provide a way to cache http requests. Read here for more details.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 5 at 9:56









        Delwyn Pinto

        685




        685






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147952%2foffline-data-cache-for-cordova-mobile-application%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            這個網誌中的熱門文章

            Academy of Television Arts & Sciences

            L'Équipe

            1995 France bombings