Reputation: 21120
In iOS 5, my NSURLConnection cache gets blown away if my app is terminated. How do I persist the NSURLConnection cache even after my app gets terminated and started fresh again? Caching works great as long as my app stays alive.
I am using NSURLRequestUseProtocolCachePolicy
in my NSURLRequest.
Sample header returned by my server:
Cache-Control:public, max-age=3600
Content-Encoding:deflate
Content-Length:1606
Content-Type:application/json; charset=utf-8
Date:Sun, 16 Sep 2012 20:22:14 GMT
Expires:Sun, 16 Sep 2012 21:22:15 GMT
Last-Modified:Sun, 16 Sep 2012 20:22:15 GMT
Vary:*
If my app is terminated after 5 minutes and I restart, a full fresh download is attempted (verified with Charles http listener)...
Upvotes: 0
Views: 605
Reputation: 21120
This appears to be a result of me not setting the disk cache size. Setting it to 500MB seems to now persist my cache even if the app is terminated.
Upvotes: 1