I am developing HTML5 mobile app. I want to cache particular JSON request for 10 days using jQuery. I tried setting cache : true on the request. But I can’t specify 10 days there. Is this possible to do? Or Do I need to use HTML5 local storage.
I am developing HTML5 mobile app. I want to cache particular JSON request for
Share
You could just store the json data, with a date, which will enable you to look up the cached data before calling to the server for an update.
You can use the local storage api in html5.
For some ideas on how to use it you can look at this question.
Storing Objects in HTML5 localStorage
To know if this will work on your target mobile devices you can look at this:
http://caniuse.com/#feat=namevalue-storage
So, you can do this:
Then you can just retrieve the object and check the date and decide if you need to reload the data.
I haven’t tested this, but it should be close.