NSURLRequestCachePolicy set to ReturnCacheDataElseLoad on NSURLRequest does not write data to NSURLCache

Originator:mattmorton
Number:rdar://21120140 Date Originated:27-May-2015
Status:Open Resolved:
Product:iOS SDK Product Version:8.3
Classification:Other Bug Reproducible:YES
 
Summary:
If the cache policy is set during creation of an NSURLRequest using 
initWithURL:cachePolicy:timeoutInterval:, and a cachePolicy of ReturnCacheDataElseLoad, if there is no existing data in the cache, the data is loaded from the network, but it is not cached as expected.

If no caching is expected, the documentation should be changed to be more explicit about the caching expectations.

If caching is expected, I have included a project that exhibits the problem.

Steps to Reproduce:
Open the project, run the app, view the console in Xcode, note the date of the response

Expected Results:
The date of the response should not change after the first load of the request.

Actual Results:
The date of the response changes after all loads of the request.

Version:
iOS Simulator, version 8.3

Notes:


Configuration:
Xcode 6, Simulator

Attachments:
'cache-testing.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!