iOS 5 Cache on Auto Lock

570 views
Skip to first unread message

NMT

unread,
Dec 6, 2011, 9:29:41 AM12/6/11
to phonegap
Does iOS 5 cache content in a UIWebView when iOS devices auto-lock?

I have a Phonegap app that uses jQuery's $.ajax function to pull data
every minute. Everything works okay *except* when the iPhone or iPad
auto-locks *and* stays that way for a good 5 minutes or more before
being turned back on. In this scenario, the AJAX calls still fire (so
JS is not halted), but data does not appear to update in the app.

I've tried setting any jQuery/jQuery Mobile settings I know of to
break cache:

cache:false, //in the actual AJAX call
$.support.cors = true; //in jQuery Mobile config file
$.mobile.allowCrossDomainPages = true; //in jQuery Mobile config file
$.ajaxSetup({isLocal:true}); //in jQuery Mobile config file

I've also "white listed" the domain I'm pulling data from. The AJAX
works everywhere except in the scenario described above.

Does UIWebView have some sort of "timeout" where after its been
sleeping for a certain amount of time, it caches content?

Does iOS cache any app content when an app is static for over a set
period of time?

NMT

unread,
Dec 13, 2011, 10:40:18 AM12/13/11
to phonegap
I've done a bit more digging, and realized that iOS versions with
multitasking take a snapshot of the app's current state when the app
enters the background, that is used for the animation to move the app
to the background, and return it from the background. Here's some
background (heh) on this:

http://software-security.sans.org/blog/2011/01/14/whats-in-your-ios-image-cache-backgrounding-snapshot

It still doesn't answer the question of why the data doesn't update
when the app returns from the background however. The app is fully
functional when returning from background mode: you can switch pages,
scroll, open/close collapsible sections, and the the AJAX calls fire,
but the data seems to be cached for some reason.

NMT

unread,
Jan 16, 2012, 10:31:42 AM1/16/12
to phonegap
Further testing with SpeedLimit and iWebInspector has revealed that
after a certain period of time, the callback function for my AJAX
calls does not fire. Does Mobile Safari disable functions if X number
of unsuccessful AJAX calls, or errors thrown by a specific function?
Reply all
Reply to author
Forward
0 new messages