Diamond
Diamond

Reputation: 608

Dynamic Caching of Data in JQuery Mobile, PhoneGap Application

I just finished reading few some sparse tutorials on caching/offline and about making an Apps responsive when the user is not connected to the internet. It was quite interesting cause I have being wondering how some Apps have being doing that cause I was thinking it was some database manipulation.

I am relatively new to the caching mechanism and I really want to implement it in my next project cause I am still learning.

The few tutorials I have read talks about caching static files like pictures, .css files, .js files etc

My question is this;

**Question 1** How do I cache Dynamic Files e.g I have an Apps when a User want to view their profile, I normally implement it by sending an Ajax request to the server to populate the profile page with pictures and other profile details (texts). How Do I cache these texts and pictures since they are dynamic?

**Question 2** I am using different page (index.html, profile.html) JQuery Mobile mechanism, will this affect caching in any way because I have to refresh the page every time I am navigating to a new page so as to show my styling correctly?

This question may sound really noob but I really want to learn and I have read a lot about caching but these question were not addressed. I just hope somebody helps. thanks...

Upvotes: 1

Views: 300

Answers (1)

AtanuCSE
AtanuCSE

Reputation: 8940

Answer is given based on my knowledge so far.

1) You can store / cache things with localStorage It's preety basic so won't take a lot of time or coding or mechanism to implement. Profile data, image as encoded string can be saved in localSorage. First you will save the profile data in localStorage. Then next time after app starts you can load data from the localStorage and also in the mean time you can make a async ajax call to server to check if data is modified. If so, then you can bring that data again and update localStorage.

2) If you use localStorage then page transitions won't be a matter until you reach the localStorage size limit of 5 mb.

Upvotes: 1

Related Questions