Load dynamic content from server, reload if things were updated


#1

Hi I was hoping to load dynamic content from a server.

Now I successfully programmed the app to get JSON file from the server, that however, what normally you would do to let the app only update/reload the JSON content when the content are changed (which makes the previous loaded content accessible while offline and only to reload everything when internet access is available)?

And, what happens if instead of some text from the JSON file, I wanted to store and get images from server? Previously the app I made are mostly static, all images are packaged inside the app, all i need to was change the path names. Now I want to try something advance, to load images from server and store them locally, but will update if things were changed or deleted…

I hope this doesn’t sound so stupid to you, but going from static to dynamic does make it sounds like lot difficult to me.

Here’s an app i just created, please hv a look, I intended to revamp the app to load data dynamically soon:
http://cow.aforadrian.com

I can send u an iphone redeem code if anyone interested to hv a look for free.


#2

It seems you have little experience with backend programming. I’ll try to answer your questions.

1) If you want to reload data only when it’s outdated, you’ll have to fetch server for that information.
So when you’re connected, ask server for the date and time of the last update, and repeat it from time to time. Everytime you get a date and time that are more recent than the one you have saved before, fetch the server for updated content and store the new update’s date and time.
Try to let user know when things are up to date or offline.

2) Put your images’ URLs in the JSON you get from the server, then you can load and store them.


#3

thanks @italo-nascimento

I hv very little backend experience, the JSON file is created by EXCEL and uploaded to a server manually.
I just started learning DJANGO and hopefully I could create a database and generate JSON response in a more automated way.

See if i get this right:
So, in a primitive way, i can use another JSON file and store a version number in it.
If the number is higher than what is stored then reload content.

What about the image:
Perhaps I am missing out some major things here.
Currently I am just loading JSON directly from the server every time the app enters the view.
I guess what I should do now is to actually store the JSON to local storage/SQLITE.
Assumed I have done that and stored list of image urls…
but to get the app able to display the content offline, how do I store the image files to the local storage instead of just URLs?

many thanks, and apology in advance if this sound too basic and stupid, I am just a front end web designer and this is starting to get really complicated for me.


#4

You will need to save the images to the device using Cordova plugin and store a local path to them.