1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    mainstream is on a distinguished road

      0  

    Default Unanswered: Cache with sencha touch 2.x

    Unanswered: Cache with sencha touch 2.x


    hello,
    I develop an application using sencha touch2, and want to make this application offline. I want to know how the cache works on sencha touch 2.x.

    My application contains several lists of data.and I want to put these data in the cache after having them loaded. and also update the cache where data change.

    Can anyone explain to me, or give me example about how the cache works on sencha touch 2?

    thanks!

  2. #2
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    690
    Answers
    21
    Vote Rating
    12
    mrsunshine will become famous soon enough

      0  

    Default


    if you use the sencha command tool you can build a production build.
    the the file resources are cached triggered by the cache manifest which will be generated for you.
    you can store your data in the localstorage for offline use and sync it when you back online

    http://docs.sencha.com/touch/2-0/#!/guide/command

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    mainstream is on a distinguished road

      0  

    Default


    Thanks mrsunshine for the reply.

    I have already seen this article,but I have a problem, I dont create my application using sencha command.I dont have all files.my application is organized following the MVC pattern,but Its not generated by the sencha generate command.
    Is it possible to add the cache or I should build the application with sencha command ?

  4. #4
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    690
    Answers
    21
    Vote Rating
    12
    mrsunshine will become famous soon enough

      0  

    Default


    the easiest way is to use the sencha command.
    if you already have the mvc structure, kickstarting a new project with sencha command and the copy your files in should be such hard.

    otherwise you can generate your manifest file with a script like
    https://github.com/jamesgpearce/confess

    or write it by your own

  5. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    mainstream is on a distinguished road

      0  

    Default


    Ok,I'll create a new project and copy my files.
    I have another question, can i use localStorage to store data with json format?
    for now my application is local,and I load data from local json files. is it possible to load data from those files and put thems into the localStorage? I'am bigenner, so am a little confused...

    Thanks again!

  6. #6
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    690
    Answers
    21
    Vote Rating
    12
    mrsunshine will become famous soon enough

      0  

    Default


    regarding localstorage yes you can do this

  7. #7
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    mainstream is on a distinguished road

      0  

    Default


    thanks mrsunshine,

    I will do
    research, then i'll come back with another questions!

  8. #8
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    mainstream is on a distinguished road

      0  

    Default


    Hello, again

    I create an application project with sencha command. Normally, the app.json will automatically create a cache.manifest if i understand?
    but when I look at the application resources in the safari console, I have an applicationCache empty. it should contain index.html page no?

    please help.

  9. #9
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    690
    Answers
    21
    Vote Rating
    12
    mrsunshine will become famous soon enough

      0  

    Default


    it will only create a manifest if you do the build for production.
    also make sure that you webserver send manifest files with the correct mime type

  10. #10
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    mainstream is on a distinguished road

      0  

    Default


    Thanks mrunshine for the reply
    you mean that I have to change the developement.js file by production.js on the index.html?

    Excuse me, but I'm a beginner, and I cant find a clear example to follow ...
    If you have a simple example, pass it to me please...

Thread Participants: 1